diff --git a/plugins/libkolab/tests/LibkolabTest.php b/plugins/libkolab/tests/LibkolabTest.php new file mode 100644 index 00000000..75ac3279 --- /dev/null +++ b/plugins/libkolab/tests/LibkolabTest.php @@ -0,0 +1,76 @@ + + * + * Copyright (C) Apheleia IT + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +class LibkolabTest extends PHPUnit\Framework\TestCase +{ + public function test_html_diff_plain() + { + // Empty input + $text1 = ''; + $text2 = ''; + $diff = libkolab::html_diff($text1, $text2); + $this->assertSame('', $diff); + + $text1 = 'test plain text'; + $text2 = ''; + $diff = libkolab::html_diff($text1, $text2); + $this->assertSame('test plain text', $diff); + + $text1 = ''; + $text2 = 'test plain text'; + $diff = libkolab::html_diff($text1, $text2); + $this->assertSame('test plain text', $diff); + + $text1 = 'test plain text'; + $text2 = 'test plain text'; + $diff = libkolab::html_diff($text1, $text2); + $this->assertSame('test plain text', $diff); + + // TODO: more cases e.g. multiline + } + + public function test_html_diff_html() + { + $text1 = '

test plain text

'; + $text2 = ''; + $diff = libkolab::html_diff($text1, $text2); + $this->assertSame('

test plain text

', $diff); + + $text1 = ''; + $text2 = '

test plain text

'; + $diff = libkolab::html_diff($text1, $text2); + $this->assertSame('

test plain text

', $diff); + + $text1 = '

test plain text

'; + $text2 = 'test plain text'; + $diff = libkolab::html_diff($text1, $text2); + $this->assertSame('

test plain text

', $diff); + + $text1 = '

test plain text

'; + $text2 = '

test

'; + $diff = libkolab::html_diff($text1, $text2); + $this->assertSame('

test plain text

', $diff); + + // TODO: more cases e.g. multiline + } +}