public function TranslatorTest::testHtmlIds in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/css-selector/Tests/XPath/TranslatorTest.php \Symfony\Component\CssSelector\Tests\XPath\TranslatorTest::testHtmlIds()
@dataProvider getHtmlIdsTestData
File
- vendor/
symfony/ css-selector/ Tests/ XPath/ TranslatorTest.php, line 46
Class
Namespace
Symfony\Component\CssSelector\Tests\XPathCode
public function testHtmlIds($css, array $elementsId) {
$translator = new Translator();
$translator
->registerExtension(new HtmlExtension($translator));
$document = new \DOMDocument();
$document->strictErrorChecking = false;
$internalErrors = libxml_use_internal_errors(true);
$document
->loadHTMLFile(__DIR__ . '/Fixtures/ids.html');
$document = simplexml_import_dom($document);
$elements = $document
->xpath($translator
->cssToXPath($css));
$this
->assertCount(count($elementsId), $elementsId);
foreach ($elements as $element) {
if (null !== $element
->attributes()->id) {
$this
->assertTrue(in_array($element
->attributes()->id, $elementsId));
}
}
libxml_clear_errors();
libxml_use_internal_errors($internalErrors);
}