diff --git a/composer.json b/composer.json index 6122761..a280d4a 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ }, "require": { "php": "^5.6 || ^7.0 || ^8.0", - "laminas/laminas-dom": "~2.7.2 || ^2.8" + "symfony/css-selector": "^3.4|^4.4|^5.4|^6.0", + "symfony/dom-crawler": "^3.4|^4.4|^5.4|^6.0" }, "require-dev": { "symfony/phpunit-bridge": "^5.2 || ^6.2" diff --git a/src/MarkupAssertionsTrait.php b/src/MarkupAssertionsTrait.php index 257706d..3a80d3a 100644 --- a/src/MarkupAssertionsTrait.php +++ b/src/MarkupAssertionsTrait.php @@ -8,10 +8,8 @@ namespace SteveGrunwell\PHPUnit_Markup_Assertions; -use DOMDocument; -use Laminas\Dom\Document; -use Laminas\Dom\Document\Query; use PHPUnit\Framework\RiskyTestError; +use Symfony\Component\DomCrawler\Crawler; trait MarkupAssertionsTrait { @@ -220,15 +218,13 @@ public function assertElementNotRegExp($regexp, $selector = '', $markup = '', $m * @param string $markup The HTML for the DOMDocument. * @param string $query The DOM selector query. * - * @return \Laminas\Dom\Document\NodeList + * @return Crawler */ protected function executeDomQuery($markup, $query) { - return Query::execute( - $query, - new Document('' . $markup, Document::DOC_HTML, 'UTF-8'), - Query::TYPE_CSS - ); + $dom = new Crawler($markup); + + return $dom->filter($query); } /** @@ -277,7 +273,7 @@ protected function getInnerHtmlOfMatchedElements($markup, $query) // Loop through results and collect their innerHTML values. foreach ($results as $result) { - $document = new DOMDocument(); + $document = new \DOMDocument(); $document->appendChild($document->importNode($result->firstChild, true)); $contents[] = trim(html_entity_decode($document->saveHTML()));