protected function WebTestBase::parse

Parse content returned from curlExec using DOM and SimpleXML.

Return value

A SimpleXMLElement or FALSE on failure.

5 calls to WebTestBase::parse()
SimpleTestTest::getTestResults in drupal/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php
Get the results from a test and store them in the class array $results.
SyslogTest::testSettings in drupal/core/modules/syslog/lib/Drupal/syslog/Tests/SyslogTest.php
Tests the syslog settings page.
WebTestBase::checkForMetaRefresh in drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
Check for meta refresh tag and if found call drupalGet() recursively. This function looks for the http-equiv attribute to be set to "Refresh" and is case-sensitive.
WebTestBase::drupalPost in drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.
WebTestBase::xpath in drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
Perform an xpath search on the contents of the internal browser. The search is relative to the root element (HTML tag normally) of the page.

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php, line 1039
Definition of Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function parse() {
  if (!$this->elements) {

    // DOM can load HTML soup. But, HTML soup can throw warnings, suppress
    // them.
    $htmlDom = new DOMDocument();
    @$htmlDom
      ->loadHTML('<?xml encoding="UTF-8">' . $this
      ->drupalGetContent());
    if ($htmlDom) {
      $this
        ->pass(t('Valid HTML found on "@path"', array(
        '@path' => $this
          ->getUrl(),
      )), t('Browser'));

      // It's much easier to work with simplexml than DOM, luckily enough
      // we can just simply import our DOM tree.
      $this->elements = simplexml_import_dom($htmlDom);
    }
  }
  if (!$this->elements) {
    $this
      ->fail(t('Parsed page successfully.'), t('Browser'));
  }
  return $this->elements;
}