diff --git a/packages/framework/tests/Feature/MarkdownHeadingRendererTest.php b/packages/framework/tests/Feature/MarkdownHeadingRendererTest.php index a2ce05f455e..3ade050fa68 100644 --- a/packages/framework/tests/Feature/MarkdownHeadingRendererTest.php +++ b/packages/framework/tests/Feature/MarkdownHeadingRendererTest.php @@ -240,4 +240,44 @@ public function testCustomPageClassConfiguration() $html = (new MarkdownService($markdown, DocumentationPage::class))->parse(); $this->assertStringNotContainsString('heading-permalink', $html); } + + public function testItHandlesMultipleHeadingsWithTheSameName() + { + $markdown = <<<'MARKDOWN' + ## Heading + ## Heading + ## Unique Heading + ## With Children + ### Child Heading + ### Child Heading + ### Unique Child Heading + #### Child Heading + MARKDOWN; + + $html = (new MarkdownService($markdown, DocumentationPage::class))->parse(); + + $this->assertSame(<<<'HTML' +

Heading#

+

Heading#

+

Unique Heading#

+

With Children#

+

Child Heading#

+

Child Heading#

+

Unique Child Heading#

+

Child Heading#

+ + HTML, $html); + } + + public function testDoesNotChangeAnythingIfMultipleHeadingsWithTheSameNameAreInDifferentPages() + { + $markdown = <<<'MARKDOWN' + ## Heading + MARKDOWN; + + $html1 = (new MarkdownService($markdown, DocumentationPage::class))->parse(); + $html2 = (new MarkdownService($markdown, DocumentationPage::class))->parse(); + + $this->assertSame($html1, $html2); + } }