protected function AttributeTest::getXPathResultCount in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::getXPathResultCount()
Counts the occurrences of the given XPath query in a given HTML snippet.
Parameters
string $query: The XPath query to execute.
string $html: The HTML snippet to check.
Return value
int The number of results that are found.
4 calls to AttributeTest::getXPathResultCount()
- AttributeTest::assertClass in core/
tests/ Drupal/ Tests/ Core/ Template/ AttributeTest.php - Checks that the given CSS class is present in the given HTML snippet.
- AttributeTest::assertID in core/
tests/ Drupal/ Tests/ Core/ Template/ AttributeTest.php - Checks that the given CSS ID is present in the given HTML snippet.
- AttributeTest::assertNoClass in core/
tests/ Drupal/ Tests/ Core/ Template/ AttributeTest.php - Checks that the given CSS class is not present in the given HTML snippet.
- AttributeTest::assertNoID in core/
tests/ Drupal/ Tests/ Core/ Template/ AttributeTest.php - Checks that the given CSS ID is not present in the given HTML snippet.
File
- core/
tests/ Drupal/ Tests/ Core/ Template/ AttributeTest.php, line 441
Class
- AttributeTest
- @coversDefaultClass \Drupal\Core\Template\Attribute @group Template
Namespace
Drupal\Tests\Core\TemplateCode
protected function getXPathResultCount($query, $html) {
$document = new \DOMDocument();
$document
->loadHTML($html);
$xpath = new \DOMXPath($document);
return $xpath
->query($query)->length;
}