From 89e8699a73f85a3a6d347c4f2bdda1fdfcedc207 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 4 Jun 2026 12:36:48 +0200 Subject: [PATCH] Fix test assertions that did not verify the intended behavior --- src/NodeVisitor/CorrectnessNodeVisitor.php | 2 ++ tests/Node/TextTest.php | 4 ++-- tests/NodeVisitor/CorrectnessTest.php | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/NodeVisitor/CorrectnessNodeVisitor.php b/src/NodeVisitor/CorrectnessNodeVisitor.php index 2c1073f4c..0d4400e35 100644 --- a/src/NodeVisitor/CorrectnessNodeVisitor.php +++ b/src/NodeVisitor/CorrectnessNodeVisitor.php @@ -111,6 +111,8 @@ final class CorrectnessNodeVisitor implements NodeVisitorInterface if ($node instanceof ModuleNode) { $this->rootNodes = null; $this->hasParent = false; + + return $node; } if ($node instanceof BlockNode) { --$this->blockDepth; diff --git a/tests/Node/TextTest.php b/tests/Node/TextTest.php index 80a144552..7402da18a 100644 --- a/tests/Node/TextTest.php +++ b/tests/Node/TextTest.php @@ -45,8 +45,8 @@ class TextTest extends NodeTestCase */ public function testIsBlank($blank) { - $this->isTrue((new TextNode($blank, 1))->isBlank()); - $this->isTrue((new TextNode(\chr(0xEF).\chr(0xBB).\chr(0xBF).$blank, 1))->isBlank()); + $this->assertTrue((new TextNode($blank, 1))->isBlank()); + $this->assertTrue((new TextNode(\chr(0xEF).\chr(0xBB).\chr(0xBF).$blank, 1))->isBlank()); } public static function getIsBlankData() diff --git a/tests/NodeVisitor/CorrectnessTest.php b/tests/NodeVisitor/CorrectnessTest.php index 13694dd35..4b23d6758 100644 --- a/tests/NodeVisitor/CorrectnessTest.php +++ b/tests/NodeVisitor/CorrectnessTest.php @@ -75,7 +75,9 @@ class CorrectnessTest extends TestCase { $input = new TextNode(\chr(0xEF).\chr(0xBB).\chr(0xBF).$emptyText, 1); - $this->assertCount(0, $this->traverse($input, new EmptyNode())); + // a child template whose root content is only a BOM followed by blanks is valid: + // the visitor must accept it (no SyntaxError) and leave it untouched + $this->assertSame($input, $this->traverse($input, new EmptyNode())); } public static function getFilterBodyNodesWithBOMData()