protected function DrupalWebTestCase::parse in Drupal 7
Parse content returned from curlExec using DOM and SimpleXML.
Return value
A SimpleXMLElement or FALSE on failure.
6 calls to DrupalWebTestCase::parse()
- DrupalWebTestCase::checkForMetaRefresh in modules/
simpletest/ drupal_web_test_case.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.
- DrupalWebTestCase::drupalPost in modules/
simpletest/ drupal_web_test_case.php - Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.
- DrupalWebTestCase::xpath in modules/
simpletest/ drupal_web_test_case.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.
- LocaleUpgradePathTestCase::assertPageInLanguage in modules/
simpletest/ tests/ upgrade/ upgrade.locale.test - Asserts that a page exists and is in the specified language.
- SimpleTestFunctionalTest::getTestResults in modules/
simpletest/ simpletest.test - Get the results from a test and store them in the class array $results.
File
- modules/
simpletest/ drupal_web_test_case.php, line 2166
Class
- DrupalWebTestCase
- Test case for typical Drupal tests.
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($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;
}