loadFile() public static method

Loads an XML (or HTML) file into a DOMDocument object.
public static loadFile ( string $filename, boolean $isHtml = FALSE ) : DOMDocument
$filename string
$isHtml boolean
return DOMDocument
 /**
  * @dataProvider getReporterProvider
  *
  * @param string[] $coverageFiles
  */
 public function testGenerateClover(array $coverageFiles)
 {
     $filename1 = $this->copyCoverageFile($coverageFiles[0], $this->targetDir);
     $filename2 = $this->copyCoverageFile($coverageFiles[1], $this->targetDir);
     $coverageMerger = new CoverageMerger();
     $coverageMerger->addCoverageFromFile($filename1);
     $coverageMerger->addCoverageFromFile($filename2);
     $target = $this->targetDir . '/coverage.xml';
     static::assertFileNotExists($target);
     $coverageMerger->getReporter()->clover($target);
     static::assertFileExists($target);
     $reportXml = \PHPUnit_Util_XML::loadFile($target);
     static::assertInstanceOf('DomDocument', $reportXml, 'Incorrect clover report xml was generated');
 }
Example #2
0
 /**
  * Loads a PHPUnit configuration file.
  *
  * @param  string $filename
  */
 protected function __construct($filename)
 {
     $this->filename = $filename;
     $this->document = PHPUnit_Util_XML::loadFile($filename);
     $this->xpath    = new DOMXPath($this->document);
 }
Example #3
0
 /**
  * Runs a test from a Selenese (HTML) specification.
  *
  * @param string $filename
  */
 public function runSelenese($filename)
 {
     $document = PHPUnit_Util_XML::loadFile($filename, TRUE);
     $xpath = new DOMXPath($document);
     $rows = $xpath->query('body/table/tbody/tr');
     foreach ($rows as $row) {
         $action = NULL;
         $arguments = array();
         $columns = $xpath->query('td', $row);
         foreach ($columns as $column) {
             if ($action === NULL) {
                 $action = PHPUnit_Util_XML::nodeToText($column);
             } else {
                 $arguments[] = PHPUnit_Util_XML::nodeToText($column);
             }
         }
         if (method_exists($this, $action)) {
             call_user_func_array(array($this, $action), $arguments);
         } else {
             $this->__call($action, $arguments);
         }
     }
 }
 /**
  * Asserts that two XML documents are not equal.
  *
  * @param string $expectedFile
  * @param string $actualXml
  * @param string $message
  *
  * @since  Method available since Release 3.3.0
  */
 public static function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = '')
 {
     $expected = PHPUnit_Util_XML::loadFile($expectedFile);
     $actual = PHPUnit_Util_XML::load($actualXml);
     self::assertNotEquals($expected, $actual, $message);
 }
 /**
  * @param $filename
  * @param bool|false $isHtml
  * @param bool|false $xinclude
  * @param bool|false $strict
  *
  * @return \DOMDocument
  */
 public function loadFile($filename, $isHtml = false, $xinclude = false, $strict = false)
 {
     return \PHPUnit_Util_XML::loadFile($filename, $isHtml, $xinclude, $strict);
 }
Example #6
0
 /**
  * @param string $fileName
  *
  * @return string
  *
  * @throws \Exception
  */
 private function getStubbedXMLConf($fileName)
 {
     $filePath = realpath($fileName);
     if (!file_exists($filePath)) {
         throw new \Exception('Stub XML config file missing: ' . $fileName);
     }
     return \PHPUnit_Util_XML::loadFile($filePath, false, true, true);
 }