From ff8ed8541474592676e257fd4fb2c7a6479a5361 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Mon, 4 Oct 2021 20:31:45 -0400 Subject: [PATCH] Fix up most namespace-related failures --- tests/cases/TestTreeConstructor.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/cases/TestTreeConstructor.php b/tests/cases/TestTreeConstructor.php index cc37dc1..1905052 100644 --- a/tests/cases/TestTreeConstructor.php +++ b/tests/cases/TestTreeConstructor.php @@ -211,6 +211,7 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase { $errors = false; } if ($errors) { + $counts = array_count_values($errors); // some "old" errors are made redundant by "new" errors $obsoleteSymbolList = implode("|", [ "illegal-codepoint-for-numeric-entity", @@ -253,10 +254,21 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase { "unexpected-dash-after-double-dash-in-comment", "unexpected-bang-after-double-dash-in-comment", ]); + // some others are consistently duplicated and just need to be pruned to one + $duplicateSymbolList = implode("|", [ + "eof-in-comment", + "unexpected-null-character", + ]); for ($a = 0, $stop = sizeof($errors); $a < $stop; $a++) { if (preg_match("/^\(\d+,\d+\):? ($obsoleteSymbolList)$/", $errors[$a])) { // these errors are redundant with "new" errors unset($errors[$a]); + } elseif (preg_match("/ ($duplicateSymbolList)$/", $errors[$a])) { + // if there's more than one of the same error at the same position, just keep one + if ($counts[$errors[$a]] > 1) { + $counts[$errors[$a]]--; + unset($errors[$a]); + } } } $errors = array_values($errors); @@ -391,7 +403,7 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase { foreach ($attr as $k => $v) { $this->push($k.'="'.$v.'"'); } - if ($e->localName === "template" && $e->namespaceURI === null) { + if ($e->localName === "template" && $e->namespaceURI === ($this->ns ? Parser::HTML_NAMESPACE : null)) { $this->push("content"); $this->depth++; foreach ($e->childNodes as $n) {