public static function PHPUnit_Util_XML::load

Load an $actual document into a DOMDocument. This is called from the selector assertions.

If $actual is already a DOMDocument, it is returned with no changes. Otherwise, $actual is loaded into a new DOMDocument as either HTML or XML, depending on the value of $isHtml. If $isHtml is false and $xinclude is true, xinclude is performed on the loaded DOMDocument.

Note: prior to PHPUnit 3.3.0, this method loaded a file and not a string as it currently does. To load a file into a DOMDocument, use loadFile() instead.

@since Method available since Release 3.3.0 @author Mike Naberezny <mike@maintainable.com> @author Derek DeVries <derek@maintainable.com> @author Tobias Schlitt <toby@php.net>

Parameters

string|DOMDocument $actual:

boolean $isHtml:

string $filename:

boolean $xinclude:

Return value

DOMDocument

4 calls to PHPUnit_Util_XML::load()
PHPUnit_Framework_Assert::assertNotTag in drupal/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert.php
This assertion is the exact opposite of assertTag().
PHPUnit_Framework_Assert::assertTag in drupal/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert.php
Evaluate an HTML or XML string and assert its structure and/or contents.
PHPUnit_Util_XML::cssSelect in drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/XML.php
Parse an $actual document and return an array of DOMNodes matching the CSS $selector. If an error occurs, it will return FALSE.
PHPUnit_Util_XML::loadFile in drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/XML.php
Loads an XML (or HTML) file into a DOMDocument object.

File

drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/XML.php, line 130

Class

PHPUnit_Util_XML
XML helpers.

Code

public static function load($actual, $isHtml = FALSE, $filename = '', $xinclude = FALSE) {
  if ($actual instanceof DOMDocument) {
    return $actual;
  }
  $document = new DOMDocument();
  $internal = libxml_use_internal_errors(TRUE);
  $message = '';
  $reporting = error_reporting(0);
  if ($isHtml) {
    $loaded = $document
      ->loadHTML($actual);
  }
  else {
    $loaded = $document
      ->loadXML($actual);
  }
  if ('' !== $filename) {

    // Necessary for xinclude
    $document->documentURI = $filename;
  }
  if (!$isHtml && $xinclude) {
    $document
      ->xinclude();
  }
  foreach (libxml_get_errors() as $error) {
    $message .= $error->message;
  }
  libxml_use_internal_errors($internal);
  error_reporting($reporting);
  if ($loaded === FALSE) {
    if ($filename != '') {
      throw new PHPUnit_Framework_Exception(sprintf('Could not load "%s".%s', $filename, $message != '' ? "\n" . $message : ''));
    }
    else {
      throw new PHPUnit_Framework_Exception($message);
    }
  }
  return $document;
}