protected function FieldWebTest::xpathContent

Performs an xpath search on a certain content.

The search is relative to the root element of the $content variable.

Parameters

string $content: The html to parse.

string $xpath: The xpath string to use in the search.

array $arguments: Some arguments for the xpath.

Return value

array|FALSE The return value of the xpath search. For details on the xpath string format and return values see the SimpleXML documentation, http://php.net/manual/function.simplexml-element-xpath.php.

3 calls to FieldWebTest::xpathContent()
FieldWebTest::testAlterUrl in drupal/core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php
Tests rewriting the output to a link.
FieldWebTest::testFieldClasses in drupal/core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php
Tests the field/label/wrapper classes.
FieldWebTest::testTextRendering in drupal/core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php
Tests trimming/read-more/ellipses.

File

drupal/core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php, line 160
Contains \Drupal\views\Tests\Handler\FieldWebTest.

Class

FieldWebTest
Tests fields from within a UI.

Namespace

Drupal\views\Tests\Handler

Code

protected function xpathContent($content, $xpath, array $arguments = array()) {
  if ($elements = $this
    ->parseContent($content)) {
    $xpath = $this
      ->buildXPathQuery($xpath, $arguments);
    $result = $elements
      ->xpath($xpath);

    // Some combinations of PHP / libxml versions return an empty array
    // instead of the documented FALSE. Forcefully convert any falsish values
    // to an empty array to allow foreach(...) constructions.
    return $result ? $result : array();
  }
  else {
    return FALSE;
  }
}