1 backdrop_web_test_case.php protected BackdropWebTestCase::parse()

Parse content returned from curlExec using DOM and SimpleXML.

Return value

A SimpleXMLElement or FALSE on failure.:

File

core/modules/simpletest/backdrop_web_test_case.php, line 2097

Class

BackdropWebTestCase
Test case for typical Backdrop tests.

Code

protected function parse() {
  if (!$this->elements) {
    $htmlDom = new DOMDocument();
    // DOM can load HTML soup, which can throw warnings. Suppress them here.
    @$htmlDom->loadHTML('<?xml encoding="UTF-8">' . $this->backdropGetContent());
    if ($htmlDom) {
      $this->pass(t('Valid HTML found on "@path"', array('@path' => $this->getUrl())), t('Browser'));
      // Import our DOM tree.
      $this->elements = simplexml_import_dom($htmlDom);
    }
  }
  if (!$this->elements) {
    $this->fail(t('Parsed page successfully.'), t('Browser'));
  }

  return $this->elements;
}