Skip to content

Commit a98e054

Browse files
authored
Merge pull request #144 from voku/copilot/fix-failing-tests-php-versions
Fix reflection-based tests across PHP 7.1–8.0
2 parents 5fdc436 + 1cca16d commit a98e054

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

tests/HTML5DOMDocumentTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,9 @@ public function testNestedSingleRootFragmentWithOuterWhitespaceIsPreserved()
709709
public function testInternalWrapperHelperNameIsNotHyphenated()
710710
{
711711
$reflection = new \ReflectionProperty(\voku\helper\AbstractDomParser::class, 'domHtmlWrapperHelper');
712+
if (\PHP_VERSION_ID < 80100) {
713+
$reflection->setAccessible(true);
714+
}
712715

713716
static::assertSame('simplevokuwrapper', $reflection->getValue());
714717
static::assertStringNotContainsString('-', $reflection->getValue());

tests/HtmlDomParserTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ public function testBrokenReplaceHelperIsResetBetweenDocuments()
100100
{
101101
$property = new \ReflectionProperty(AbstractDomParser::class, 'domBrokenReplaceHelper');
102102
$keysProperty = new \ReflectionProperty(AbstractDomParser::class, 'dynamicDomBrokenReplaceHelperKeys');
103+
if (\PHP_VERSION_ID < 80100) {
104+
$property->setAccessible(true);
105+
$keysProperty->setAccessible(true);
106+
}
103107

104108
$dom = new HtmlDomParser();
105109
// The broken-replacement map is static, so seed it explicitly to
@@ -119,6 +123,9 @@ public function testBrokenReplaceHelperIsResetBetweenDocuments()
119123
public function testHasMultipleTopLevelNodesRestoresLibxmlState()
120124
{
121125
$method = new \ReflectionMethod(HtmlDomParser::class, 'hasMultipleTopLevelNodes');
126+
if (\PHP_VERSION_ID < 80100) {
127+
$method->setAccessible(true);
128+
}
122129

123130
$dom = new HtmlDomParser();
124131
$originalInternalErrors = \libxml_use_internal_errors(false);

tests/SimpleHtmlDomTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,9 @@ public function testLookupValueHelpersAndRemovedNodeState()
760760

761761
$corrupted = new SimpleHtmlDom(new \DOMElement('free'));
762762
$nodeProperty = new \ReflectionProperty(\voku\helper\AbstractSimpleHtmlDom::class, 'node');
763+
if (\PHP_VERSION_ID < 80100) {
764+
$nodeProperty->setAccessible(true);
765+
}
763766
$nodeProperty->setValue($corrupted, new \stdClass());
764767
static::assertTrue($corrupted->isRemoved());
765768

0 commit comments

Comments
 (0)