panther
panther copied to clipboard
Refactor PantherCrawler to allow passing the HTML as string to the constructor
Loosely following up on https://github.com/symfony/panther/issues/431, here's another idea:
Symfony's DomCrawler can be constructed by just passing the HTML:
$domCrawler = new DomCrawler('<html>foo</html>');
I'm suggesting to allow the same for PantherCrawler: https://github.com/symfony/panther/blob/main/src/DomCrawler/Crawler.php#L37
My use case: I wanted to write some unit tests to assert the behavior of the two crawlers (see https://github.com/symfony/panther/issues/457), but couldn't find a way to instantiate PantherCrawler. So I ended up in creating a controller, and firing up the entire browser engine in my test, just to see how ->text() handles <br> ;-)