From 55270a0e401c2a18944c7ad5eb2fc3cf67ed55f3 Mon Sep 17 00:00:00 2001 From: James Mayell Date: Sun, 26 Jul 2026 11:50:05 +0100 Subject: [PATCH 1/2] fix: break after finding ini comment --- src/CommentIni.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CommentIni.php b/src/CommentIni.php index 248adf0..c3cf641 100644 --- a/src/CommentIni.php +++ b/src/CommentIni.php @@ -70,6 +70,7 @@ private function findIniComment(iterable $walker):array { $this->assertCommentIsLeadingNode($commentNode); $commentNodeToRemove = $commentNode; + break; } return [$commentNodeToRemove, $ini]; From f31adc0f27772f6318809e3325bc06de060c640f Mon Sep 17 00:00:00 2001 From: James Mayell Date: Sun, 26 Jul 2026 13:02:58 +0100 Subject: [PATCH 2/2] tweak: added test --- test/phpunit/CommentIniTest.php | 7 +++++++ test/phpunit/TestHelper/HTMLPageContent.php | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/test/phpunit/CommentIniTest.php b/test/phpunit/CommentIniTest.php index ab9acac..1ce752e 100644 --- a/test/phpunit/CommentIniTest.php +++ b/test/phpunit/CommentIniTest.php @@ -35,6 +35,13 @@ public function testContainsIniData_emptyIfMalformedIniSyntax():void { self::assertStringContainsString("something: broken", $document->saveHTML()); } + public function testContainsIniData_onlyFindsFirstComment():void { + $document = new HTMLDocument(HTMLPageContent::HTML_COMMENT_WITH_INI_AND_ANOTHER_COMMENT); + $sut = new CommentIni($document); + self::assertTrue($sut->containsIniData()); + self::assertEquals("base-page", $sut->get("extends")); + } + public function testGet_noMatchingData():void { $document = new HTMLDocument(HTMLPageContent::HTML_EXTENDS_PARTIAL_VIEW); $sut = new CommentIni($document); diff --git a/test/phpunit/TestHelper/HTMLPageContent.php b/test/phpunit/TestHelper/HTMLPageContent.php index f234317..19b56d2 100644 --- a/test/phpunit/TestHelper/HTMLPageContent.php +++ b/test/phpunit/TestHelper/HTMLPageContent.php @@ -934,6 +934,16 @@ class HTMLPageContent {

Hello from within a sub-template!

+HTML; + + const HTML_COMMENT_WITH_INI_AND_ANOTHER_COMMENT = << +
+ +

Hello from within a sub-template!

+
HTML; const HTML_COMPONENT = <<