Skip to content

Commit 9eec15b

Browse files
vokuCopilot
andcommitted
Fix cross-version coverage test assertions
Make the coverage regression test assert the restored script output across PHP versions and use a mutable detached XML element for the attribute branch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2506614 commit 9eec15b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tests/CoverageBoostTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ public function exposeHtml5FallbackForScriptTags(string &$html): void
466466
$fallbackParser->exposeHtml5FallbackForScriptTags($scriptHtml);
467467
static::assertSame(
468468
'<script src="a.js"></script><script>if (a) { document.write("<\/tag>"); }</script>',
469-
$scriptHtml
469+
HtmlDomParser::putReplacedBackToPreserveHtmlEntities($scriptHtml)
470470
);
471471

472472
static::assertSame($fallbackParser, $fallbackParser->overwriteSpecialScriptTags(['text/x-custom', 'text/custom']));
@@ -525,9 +525,12 @@ public function callClean(HtmlDomParser $newDocument, bool $removeExtraHeadTag =
525525
$detachedXmlElement->innertext = '<entry>new</entry>';
526526
$detachedXmlElement->outertext = '';
527527
$detachedXmlElement->plaintext = '';
528-
$detachedXmlElement->setAttribute('id', 'value');
529528
static::assertSame('free', $detachedXmlElement->tag);
530529

530+
$mutableDetachedXmlElement = new SimpleXmlDom((new \DOMDocument())->createElement('free'));
531+
$mutableDetachedXmlElement->setAttribute('id', 'value');
532+
static::assertSame('value', $mutableDetachedXmlElement->getAttribute('id'));
533+
531534
$xmlFile = \tempnam(\sys_get_temp_dir(), 'simple-xml-dom-xml');
532535
$htmlFile = \tempnam(\sys_get_temp_dir(), 'simple-xml-dom-html');
533536
static::assertNotFalse($xmlFile);

0 commit comments

Comments
 (0)