. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Factories; use Fisharebest\Webtrees\TestCase; use Fisharebest\Webtrees\Tree; /** * Test harness for the class MarkdownFactory * * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory */ class MarkdownFactoryTest extends TestCase { /** * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory */ public function testAutoLinkWithoutTree(): void { $factory = new MarkdownFactory(); static::assertSame( "FOO https://example.com BAR", $factory->autolink('FOO https://example.com BAR') ); } /** * @covers \Fisharebest\Webtrees\CommonMark\XrefExtension * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory */ public function testAutoLinkWithTree(): void { $factory = new MarkdownFactory(); $tree = $this->createStub(Tree::class); static::assertSame( "FOO https://example.com BAR", $factory->autolink('FOO https://example.com BAR', $tree) ); } /** * @covers \Fisharebest\Webtrees\CommonMark\XrefExtension * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory */ public function testAutoLinkWithHtml(): void { $factory = new MarkdownFactory(); static::assertSame( "<b> https://example.com </b>", $factory->autolink(' https://example.com ') ); } /** * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory */ public function testMarkdownWithoutTree(): void { $factory = new MarkdownFactory(); static::assertSame( "

FOO https://example.com BAR

\n", $factory->markdown('FOO https://example.com BAR') ); static::assertSame( "

FOO https://example.com BAR

\n", $factory->markdown('FOO BAR') ); } /** * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory */ public function testMarkdownWithTree(): void { $tree = $this->createStub(Tree::class); $factory = new MarkdownFactory(); static::assertSame( "

FOO https://example.com BAR

\n", $factory->markdown('FOO https://example.com BAR', $tree) ); static::assertSame( "

FOO https://example.com BAR

\n", $factory->markdown('FOO BAR', $tree) ); } /** * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory */ public function testMarkdownWithHtml(): void { $factory = new MarkdownFactory(); static::assertSame( "

<b> https://example.com </b>

\n", $factory->markdown(' ') ); } /** * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory */ public function testSoftLineBreaks(): void { $factory = new MarkdownFactory(); static::assertSame( "alpha
beta
gamma
\ndelta", $factory->autolink("alpha\nbeta\ngamma \ndelta") ); static::assertSame( "

alpha
beta
gamma
\ndelta

\n", $factory->markdown("alpha\nbeta\ngamma \ndelta") ); } /** * @covers \Fisharebest\Webtrees\Factories\MarkdownFactory */ public function testMultipleParagraphs(): void { $factory = new MarkdownFactory(); static::assertSame( "alpha
beta

gamma
delta", $factory->autolink("alpha\nbeta\n\n\n\ngamma\ndelta") ); static::assertSame( "

alpha
beta

\n

gamma
delta

\n", $factory->markdown("alpha\nbeta\n\n\n\ngamma\ndelta") ); } }