diff options
| author | Greg Roach <greg@subaqua.co.uk> | 2021-11-21 09:11:15 +0000 |
|---|---|---|
| committer | Greg Roach <greg@subaqua.co.uk> | 2021-11-21 11:04:46 +0000 |
| commit | dbfdfe6ba0c8deebeb0f78289edb079de71bb063 (patch) | |
| tree | b13271416c4b38ad4f1117f2db977c9573153c72 /tests/app | |
| parent | 4348fc0254475e33d56e6ce220a66ba884c01734 (diff) | |
| download | webtrees-dbfdfe6ba0c8deebeb0f78289edb079de71bb063.tar.gz webtrees-dbfdfe6ba0c8deebeb0f78289edb079de71bb063.tar.bz2 webtrees-dbfdfe6ba0c8deebeb0f78289edb079de71bb063.zip | |
CodeStyle
Diffstat (limited to 'tests/app')
| -rw-r--r-- | tests/app/Factories/MarkdownFactoryTest.php | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/tests/app/Factories/MarkdownFactoryTest.php b/tests/app/Factories/MarkdownFactoryTest.php new file mode 100644 index 0000000000..2f9af0a203 --- /dev/null +++ b/tests/app/Factories/MarkdownFactoryTest.php @@ -0,0 +1,133 @@ +<?php + +/** + * webtrees: online genealogy + * Copyright (C) 2021 webtrees development team + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +declare(strict_types=1); + +namespace Fisharebest\Webtrees\Factories; + +use Fisharebest\Webtrees\TestCase; +use Fisharebest\Webtrees\Tree; + +/** + * Test harness for the class GedcomEditService + * + * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory + */ +class MarkdownFactoryTest extends TestCase +{ + /** + * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory + */ + public function testAutoLinkWithoutTree(): void + { + $factory = new MarkdownFactory(); + $autolink = $factory->autolink(); + + $this->assertSame( + "<p>FOO <a href=\"https://example.com\">https://example.com</a> BAR</p>\n", + $autolink->convertToHtml('FOO https://example.com BAR') + ); + } + + /** + * @covers \Fisharebest\Webtrees\CommonMark\XrefExtension + * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory + */ + public function testAutoLinkWithTree(): void + { + $tree = $this->createStub(Tree::class); + + $factory = new MarkdownFactory(); + $autolink = $factory->autolink($tree); + + $this->assertSame( + "<p>FOO <a href=\"https://example.com\">https://example.com</a> BAR</p>\n", + $autolink->convertToHtml('FOO https://example.com BAR') + ); + } + + /** + * @covers \Fisharebest\Webtrees\CommonMark\XrefExtension + * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory + */ + public function testAutoLinkWithHtml(): void + { + $factory = new MarkdownFactory(); + $autolink = $factory->autolink(); + + $this->assertSame( + "<p><b> <a href=\"https://example.com\">https://example.com</a> </b></p>\n", + $autolink->convertToHtml('<b> https://example.com </b>') + ); + } + + /** + * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory + */ + public function testMarkdownWithoutTree(): void + { + $factory = new MarkdownFactory(); + $Markdown = $factory->Markdown(); + + $this->assertSame( + "<p>FOO https://example.com BAR</p>\n", + $Markdown->convertToHtml('FOO https://example.com BAR') + ); + + $this->assertSame( + "<p>FOO <a href=\"https://example.com\">https://example.com</a> BAR</p>\n", + $Markdown->convertToHtml('FOO <https://example.com> BAR') + ); + } + + /** + * @covers \Fisharebest\Webtrees\CommonMark\XrefExtension + * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory + */ + public function testMarkdownWithTree(): void + { + $tree = $this->createStub(Tree::class); + + $factory = new MarkdownFactory(); + $Markdown = $factory->Markdown($tree); + + $this->assertSame( + "<p>FOO https://example.com BAR</p>\n", + $Markdown->convertToHtml('FOO https://example.com BAR') + ); + + $this->assertSame( + "<p>FOO <a href=\"https://example.com\">https://example.com</a> BAR</p>\n", + $Markdown->convertToHtml('FOO <https://example.com> BAR') + ); + } + + /** + * @covers \Fisharebest\Webtrees\CommonMark\XrefExtension + * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory + */ + public function testMarkdownWithHtml(): void + { + $factory = new MarkdownFactory(); + $markdown = $factory->Markdown(); + + $this->assertSame( + "<p><b> <a href=\"https://example.com\">https://example.com</a> </b></p>\n", + $markdown->convertToHtml('<b> <https://example.com> </b>') + ); + } +} |
