diff --git a/packages/framework/tests/Unit/HeadingRendererUnitTest.php b/packages/framework/tests/Unit/HeadingRendererUnitTest.php index 79544abac99..d02d3298aca 100644 --- a/packages/framework/tests/Unit/HeadingRendererUnitTest.php +++ b/packages/framework/tests/Unit/HeadingRendererUnitTest.php @@ -14,6 +14,7 @@ use League\CommonMark\Node\Node; use League\CommonMark\Renderer\ChildNodeRendererInterface; use Mockery; +use PHPUnit\Framework\Attributes\TestWith; /** * @covers \Hyde\Markdown\Processing\HeadingRenderer @@ -234,13 +235,14 @@ public function testPostProcessHandlesNoHeadingTags() $this->assertSame('
Paragraph
', (new HeadingRenderer())->postProcess($html)); } - public function testHeadingIdentifierGeneration() + #[TestWith(['hello world', 'hello-world'])] + #[TestWith(['hello-world', 'hello-world'])] + #[TestWith(['hello_world', 'hello-world'])] + #[TestWith(['user@host', 'user-at-host'])] + #[TestWith(['', ''])] + public function testHeadingIdentifierGeneration(string $input, string $expected): void { - $this->assertSame('hello-world', HeadingRenderer::makeIdentifier('hello world')); - $this->assertSame('hello-world', HeadingRenderer::makeIdentifier('hello-world')); - $this->assertSame('hello-world', HeadingRenderer::makeIdentifier('hello_world')); - $this->assertSame('user-at-host', HeadingRenderer::makeIdentifier('user@host')); - $this->assertSame('', HeadingRenderer::makeIdentifier('')); + $this->assertSame($expected, HeadingRenderer::makeIdentifier($input)); } protected function mockChildNodeRenderer(string $contents = 'Test Heading'): ChildNodeRendererInterface