Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit strict error handling in XML::load() to configuration #1386

Merged
merged 1 commit into from
Aug 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Util/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class PHPUnit_Util_Configuration
protected function __construct($filename)
{
$this->filename = $filename;
$this->document = PHPUnit_Util_XML::loadFile($filename, false, true);
$this->document = PHPUnit_Util_XML::loadFile($filename, false, true, true);
$this->xpath = new DOMXPath($this->document);
}

Expand Down
10 changes: 6 additions & 4 deletions src/Util/XML.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ public static function prepareString($string)
* @param string $filename
* @param boolean $isHtml
* @param boolean $xinclude
* @param boolean $strict
* @return DOMDocument
* @since Method available since Release 3.3.0
*/
public static function loadFile($filename, $isHtml = false, $xinclude = false)
public static function loadFile($filename, $isHtml = false, $xinclude = false, $strict = false)
{
$reporting = error_reporting(0);
$contents = file_get_contents($filename);
Expand All @@ -102,7 +103,7 @@ public static function loadFile($filename, $isHtml = false, $xinclude = false)
);
}

return self::load($contents, $isHtml, $filename, $xinclude);
return self::load($contents, $isHtml, $filename, $xinclude, $strict);
}

/**
Expand All @@ -123,13 +124,14 @@ public static function loadFile($filename, $isHtml = false, $xinclude = false)
* @param boolean $isHtml
* @param string $filename
* @param boolean $xinclude
* @param boolean $strict
* @return DOMDocument
* @since Method available since Release 3.3.0
* @author Mike Naberezny <[email protected]>
* @author Derek DeVries <[email protected]>
* @author Tobias Schlitt <[email protected]>
*/
public static function load($actual, $isHtml = false, $filename = '', $xinclude = false)
public static function load($actual, $isHtml = false, $filename = '', $xinclude = false, $strict = false)
{
if ($actual instanceof DOMDocument) {
return $actual;
Expand Down Expand Up @@ -173,7 +175,7 @@ public static function load($actual, $isHtml = false, $filename = '', $xinclude
chdir($cwd);
}

if ($loaded === false || $message !== '') {
if ($loaded === false || ($strict && $message !== '')) {
if ($filename !== '') {
throw new PHPUnit_Framework_Exception(
sprintf(
Expand Down