function AssertContentTrait::getSimpleXmlElementsByXpath
Performs an xpath search on the contents of the internal browser.
The search is relative to the root element (HTML tag normally) of the page.
Parameters
string $xpath: The xpath string to use in the search.
array $arguments: An array of arguments with keys in the form ':name' matching the placeholders in the query. The values may be either strings or numeric values.
Return value
\SimpleXMLElement[]|false The return value of the xpath search or FALSE on failure. For details on the xpath string format and return values see the SimpleXML documentation.
See also
http://php.net/manual/function.simplexml-element-xpath.php
14 calls to AssertContentTrait::getSimpleXmlElementsByXpath()
- AreaEntityTest::doTestRender in core/
modules/ views/ tests/ src/ Kernel/ Handler/ AreaEntityTest.php - Tests rendering the entity area handler.
- DisplayPageTest::testEmptyRow in core/
modules/ views/ tests/ src/ Kernel/ Plugin/ DisplayPageTest.php - Tests the templates with empty rows.
- DisplayPageTest::testReadMore in core/
modules/ views/ tests/ src/ Kernel/ Plugin/ DisplayPageTest.php - Tests the 'read more' functionality.
- ElementsFieldsetTest::testFieldsetDescriptions in core/
modules/ system/ tests/ src/ Kernel/ Form/ ElementsFieldsetTest.php - Tests different display options for fieldset element descriptions.
- ExposedFormRenderTest::testExposedFormRender in core/
modules/ views/ tests/ src/ Kernel/ Plugin/ ExposedFormRenderTest.php - Tests the exposed form markup.
File
-
core/
tests/ Drupal/ KernelTests/ AssertContentTrait.php, line 230
Class
- AssertContentTrait
- Provides test methods to assert content.
Namespace
Drupal\KernelTestsCode
protected function getSimpleXmlElementsByXpath(string $xpath, array $arguments = []) : array|false {
if ($this->parse()) {
$xpath = $this->buildXPathQuery($xpath, $arguments);
$result = $this->elements
->xpath($xpath);
// Some combinations of PHP / libxml versions return an empty array
// instead of the documented FALSE. Forcefully convert any falsy values
// to an empty array to allow foreach(...) constructions.
return $result ?: [];
}
return FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.