1dbfdfe6bSGreg Roach<?php 2dbfdfe6bSGreg Roach 3dbfdfe6bSGreg Roach/** 4dbfdfe6bSGreg Roach * webtrees: online genealogy 5dbfdfe6bSGreg Roach * Copyright (C) 2021 webtrees development team 6dbfdfe6bSGreg Roach * This program is free software: you can redistribute it and/or modify 7dbfdfe6bSGreg Roach * it under the terms of the GNU General Public License as published by 8dbfdfe6bSGreg Roach * the Free Software Foundation, either version 3 of the License, or 9dbfdfe6bSGreg Roach * (at your option) any later version. 10dbfdfe6bSGreg Roach * This program is distributed in the hope that it will be useful, 11dbfdfe6bSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12dbfdfe6bSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13dbfdfe6bSGreg Roach * GNU General Public License for more details. 14dbfdfe6bSGreg Roach * You should have received a copy of the GNU General Public License 15dbfdfe6bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16dbfdfe6bSGreg Roach */ 17dbfdfe6bSGreg Roach 18dbfdfe6bSGreg Roachdeclare(strict_types=1); 19dbfdfe6bSGreg Roach 20dbfdfe6bSGreg Roachnamespace Fisharebest\Webtrees\Factories; 21dbfdfe6bSGreg Roach 22dbfdfe6bSGreg Roachuse Fisharebest\Webtrees\TestCase; 23dbfdfe6bSGreg Roachuse Fisharebest\Webtrees\Tree; 24dbfdfe6bSGreg Roach 25dbfdfe6bSGreg Roach/** 26*d4ec5ec0SGreg Roach * Test harness for the class MarkdownFactory 27dbfdfe6bSGreg Roach * 28dbfdfe6bSGreg Roach * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory 29dbfdfe6bSGreg Roach */ 30dbfdfe6bSGreg Roachclass MarkdownFactoryTest extends TestCase 31dbfdfe6bSGreg Roach{ 32dbfdfe6bSGreg Roach /** 33dbfdfe6bSGreg Roach * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory 34dbfdfe6bSGreg Roach */ 35dbfdfe6bSGreg Roach public function testAutoLinkWithoutTree(): void 36dbfdfe6bSGreg Roach { 37dbfdfe6bSGreg Roach $factory = new MarkdownFactory(); 38dbfdfe6bSGreg Roach 39dbfdfe6bSGreg Roach $this->assertSame( 40dbfdfe6bSGreg Roach "<p>FOO <a href=\"https://example.com\">https://example.com</a> BAR</p>\n", 416f595250SGreg Roach $factory->autolink('FOO https://example.com BAR') 42dbfdfe6bSGreg Roach ); 43dbfdfe6bSGreg Roach } 44dbfdfe6bSGreg Roach 45dbfdfe6bSGreg Roach /** 46dbfdfe6bSGreg Roach * @covers \Fisharebest\Webtrees\CommonMark\XrefExtension 47dbfdfe6bSGreg Roach * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory 48dbfdfe6bSGreg Roach */ 49dbfdfe6bSGreg Roach public function testAutoLinkWithTree(): void 50dbfdfe6bSGreg Roach { 51dbfdfe6bSGreg Roach $factory = new MarkdownFactory(); 526f595250SGreg Roach $tree = $this->createStub(Tree::class); 53dbfdfe6bSGreg Roach 54dbfdfe6bSGreg Roach $this->assertSame( 55dbfdfe6bSGreg Roach "<p>FOO <a href=\"https://example.com\">https://example.com</a> BAR</p>\n", 566f595250SGreg Roach $factory->autolink('FOO https://example.com BAR', $tree) 57dbfdfe6bSGreg Roach ); 58dbfdfe6bSGreg Roach } 59dbfdfe6bSGreg Roach 60dbfdfe6bSGreg Roach /** 61dbfdfe6bSGreg Roach * @covers \Fisharebest\Webtrees\CommonMark\XrefExtension 62dbfdfe6bSGreg Roach * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory 63dbfdfe6bSGreg Roach */ 64dbfdfe6bSGreg Roach public function testAutoLinkWithHtml(): void 65dbfdfe6bSGreg Roach { 66dbfdfe6bSGreg Roach $factory = new MarkdownFactory(); 67dbfdfe6bSGreg Roach 68dbfdfe6bSGreg Roach $this->assertSame( 69dbfdfe6bSGreg Roach "<p><b> <a href=\"https://example.com\">https://example.com</a> </b></p>\n", 706f595250SGreg Roach $factory->autolink('<b> https://example.com </b>') 71dbfdfe6bSGreg Roach ); 72dbfdfe6bSGreg Roach } 73dbfdfe6bSGreg Roach 74dbfdfe6bSGreg Roach /** 75dbfdfe6bSGreg Roach * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory 76dbfdfe6bSGreg Roach */ 77dbfdfe6bSGreg Roach public function testMarkdownWithoutTree(): void 78dbfdfe6bSGreg Roach { 79dbfdfe6bSGreg Roach $factory = new MarkdownFactory(); 80dbfdfe6bSGreg Roach 81dbfdfe6bSGreg Roach $this->assertSame( 82dbfdfe6bSGreg Roach "<p>FOO https://example.com BAR</p>\n", 836f595250SGreg Roach $factory->markdown('FOO https://example.com BAR') 84dbfdfe6bSGreg Roach ); 85dbfdfe6bSGreg Roach 86dbfdfe6bSGreg Roach $this->assertSame( 87dbfdfe6bSGreg Roach "<p>FOO <a href=\"https://example.com\">https://example.com</a> BAR</p>\n", 886f595250SGreg Roach $factory->markdown('FOO <https://example.com> BAR') 89dbfdfe6bSGreg Roach ); 90dbfdfe6bSGreg Roach } 91dbfdfe6bSGreg Roach 92dbfdfe6bSGreg Roach /** 93dbfdfe6bSGreg Roach * @covers \Fisharebest\Webtrees\CommonMark\XrefExtension 94dbfdfe6bSGreg Roach * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory 95dbfdfe6bSGreg Roach */ 96dbfdfe6bSGreg Roach public function testMarkdownWithTree(): void 97dbfdfe6bSGreg Roach { 98dbfdfe6bSGreg Roach $tree = $this->createStub(Tree::class); 99dbfdfe6bSGreg Roach $factory = new MarkdownFactory(); 100dbfdfe6bSGreg Roach 101dbfdfe6bSGreg Roach $this->assertSame( 102dbfdfe6bSGreg Roach "<p>FOO https://example.com BAR</p>\n", 1036f595250SGreg Roach $factory->markdown('FOO https://example.com BAR', $tree) 104dbfdfe6bSGreg Roach ); 105dbfdfe6bSGreg Roach 106dbfdfe6bSGreg Roach $this->assertSame( 107dbfdfe6bSGreg Roach "<p>FOO <a href=\"https://example.com\">https://example.com</a> BAR</p>\n", 1086f595250SGreg Roach $factory->markdown('FOO <https://example.com> BAR', $tree) 109dbfdfe6bSGreg Roach ); 110dbfdfe6bSGreg Roach } 111dbfdfe6bSGreg Roach 112dbfdfe6bSGreg Roach /** 113dbfdfe6bSGreg Roach * @covers \Fisharebest\Webtrees\CommonMark\XrefExtension 114dbfdfe6bSGreg Roach * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory 115dbfdfe6bSGreg Roach */ 116dbfdfe6bSGreg Roach public function testMarkdownWithHtml(): void 117dbfdfe6bSGreg Roach { 118dbfdfe6bSGreg Roach $factory = new MarkdownFactory(); 119dbfdfe6bSGreg Roach 120dbfdfe6bSGreg Roach $this->assertSame( 121dbfdfe6bSGreg Roach "<p><b> <a href=\"https://example.com\">https://example.com</a> </b></p>\n", 1226f595250SGreg Roach $factory->markdown('<b> <https://example.com> </b>') 123dbfdfe6bSGreg Roach ); 124dbfdfe6bSGreg Roach } 125dbfdfe6bSGreg Roach} 126