function AttributeTest::getXPathResultCount
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::getXPathResultCount()
- 10 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::getXPathResultCount()
- 11.x 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 449
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.