Skip to content

Commit da9e54a

Browse files
minor #49669 [DomCrawler] Improve html5Parser tests (victor-prdh)
This PR was squashed before being merged into the 6.3 branch. Discussion ---------- [DomCrawler] Improve html5Parser tests | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | / | License | MIT | Doc PR | / Hi ! As mentioned by `@Bilge` in #49121 (comment), test to ensure the new html5Parser strategy wasn't the best ! So i worked a little on this subject and i come with this new proposal ! Thanks Commits ------- 1231d75 [DomCrawler] Improve html5Parser tests
2 parents dc01681 + 1231d75 commit da9e54a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Symfony/Component/DomCrawler/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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy