Skip to content

Commit 207c5e2

Browse files
victor-prdhnicolas-grekas
authored andcommitted
[DomCrawler] Improve html5Parser tests
1 parent 64a4ec5 commit 207c5e2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Tests/Html5ParserCrawlerTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,24 @@ public function testHtml5ParserNotSameAsNativeParserForSpecificHtml()
6060
$this->assertNotEquals($nativeCrawler->filterXPath('//h1')->text(), $html5Crawler->filterXPath('//h1')->text(), 'Native parser and Html5 parser must be different');
6161
}
6262

63+
/**
64+
* @testWith [true]
65+
* [false]
66+
*/
67+
public function testHasHtml5Parser(bool $useHtml5Parser)
68+
{
69+
$crawler = $this->createCrawler(null, null, null, $useHtml5Parser);
70+
71+
$r = new \ReflectionProperty($crawler::class, 'html5Parser');
72+
$html5Parser = $r->getValue($crawler);
73+
74+
if ($useHtml5Parser) {
75+
$this->assertInstanceOf(\Masterminds\HTML5::class, $html5Parser, 'Html5Parser must be a Masterminds\HTML5 instance');
76+
} else {
77+
$this->assertNull($html5Parser, 'Html5Parser must be null');
78+
}
79+
}
80+
6381
public static function validHtml5Provider(): iterable
6482
{
6583
$html = self::getDoctype().'<html><body><h1><p>Foo</p></h1></body></html>';

0 commit comments

Comments
 (0)