. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Factories; use Fisharebest\Webtrees\CommonMark\XrefExtension; use Fisharebest\Webtrees\TestCase; use Fisharebest\Webtrees\Tree; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(MarkdownFactory::class)] #[CoversClass(XrefExtension::class)] class MarkdownFactoryTest extends TestCase { public function testAutoLinkWithoutTree(): void { $factory = new MarkdownFactory(); static::assertSame( '

FOO https://example.com BAR

', $factory->autolink('FOO https://example.com BAR') ); } public function testAutoLinkWithTree(): void { $factory = new MarkdownFactory(); $tree = $this->createMock(Tree::class); static::assertSame( '

FOO https://example.com BAR

', $factory->autolink('FOO https://example.com BAR', $tree) ); } public function testAutoLinkWithHtml(): void { $factory = new MarkdownFactory(); static::assertSame( '

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

', $factory->autolink(' https://example.com ') ); } public function testMarkdownWithoutTree(): void { $factory = new MarkdownFactory(); static::assertSame( '

FOO https://example.com BAR

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

FOO https://example.com BAR

', $factory->markdown('FOO BAR') ); } public function testMarkdownWithTree(): void { $tree = $this->createMock(Tree::class); $factory = new MarkdownFactory(); static::assertSame( '

FOO https://example.com BAR

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

FOO https://example.com BAR

', $factory->markdown('FOO BAR', $tree) ); } public function testMarkdownWithHtml(): void { $factory = new MarkdownFactory(); static::assertSame( '

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

', $factory->markdown(' ') ); } public function testSoftLineBreaks(): void { $factory = new MarkdownFactory(); static::assertSame( '

alpha
beta
gamma
delta

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

alpha
beta
gamma
delta

', $factory->markdown("alpha\nbeta\ngamma \ndelta") ); } 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

gamma
delta

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