diff --git a/dev/CSSContentParser.php b/dev/CSSContentParser.php index 246896377..fc7dc7f8f 100644 --- a/dev/CSSContentParser.php +++ b/dev/CSSContentParser.php @@ -17,7 +17,7 @@ class CSSContentParser extends Object { function __construct($content) { $CLI_content = escapeshellarg($content); - $tidy = `echo $CLI_content | tidy -n -q -utf8 -asxhtml`; + $tidy = `echo $CLI_content | tidy -n -q -utf8 -asxhtml 2> /dev/null`; $tidy = str_replace('xmlns="http://www.w3.org/1999/xhtml"','',$tidy); $tidy = str_replace(' ','',$tidy); $this->simpleXML = new SimpleXMLElement($tidy); diff --git a/dev/FunctionalTest.php b/dev/FunctionalTest.php index 7118bc9d8..16ab4d06a 100644 --- a/dev/FunctionalTest.php +++ b/dev/FunctionalTest.php @@ -142,12 +142,14 @@ class FunctionalTest extends SapphireTest { */ function assertPartialMatchBySelector($selector, $expectedMatches) { $items = $this->cssParser()->getBySelector($selector); - foreach($items as $item) $actuals[trim(preg_replace("/[ \n\r\t]+/", " ", $item. ''))] = true; + + $actuals = array(); + if($items) foreach($items as $item) $actuals[trim(preg_replace("/[ \n\r\t]+/", " ", $item. ''))] = true; foreach($expectedMatches as $match) { if(!isset($actuals[$match])) { throw new PHPUnit_Framework_AssertionFailedError( - "Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "\n\n" + "Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "'\n\n" . "Instead the following elements were found:\n'" . implode("'\n'", array_keys($actuals)) . "'" ); return; @@ -168,11 +170,13 @@ class FunctionalTest extends SapphireTest { */ function assertExactMatchBySelector($selector, $expectedMatches) { $items = $this->cssParser()->getBySelector($selector); - foreach($items as $item) $actuals[] = trim(preg_replace("/[ \n\r\t]+/", " ", $item. '')); + + $actuals = array(); + if($items) foreach($items as $item) $actuals[] = trim(preg_replace("/[ \n\r\t]+/", " ", $item. '')); if($expectedMatches != $actuals) { throw new PHPUnit_Framework_AssertionFailedError( - "Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "\n\n" + "Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "'\n\n" . "Instead the following elements were found:\n'" . implode("'\n'", $actuals) . "'" ); } @@ -190,12 +194,14 @@ class FunctionalTest extends SapphireTest { */ function assertPartialHTMLMatchBySelector($selector, $expectedMatches) { $items = $this->cssParser()->getBySelector($selector); - foreach($items as $item) $actuals[$item->asXML()] = true; + + $actuals = array(); + if($items) foreach($items as $item) $actuals[$item->asXML()] = true; foreach($expectedMatches as $match) { if(!isset($actuals[$match])) { throw new PHPUnit_Framework_AssertionFailedError( - "Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "\n\n" + "Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "'\n\n" . "Instead the following elements were found:\n'" . implode("'\n'", array_keys($actuals)) . "'" ); return; @@ -216,11 +222,13 @@ class FunctionalTest extends SapphireTest { */ function assertExactHTMLMatchBySelector($selector, $expectedMatches) { $items = $this->cssParser()->getBySelector($selector); - foreach($items as $item) $actuals[] = $item->asXML(); + + $actuals = array(); + if($items) foreach($items as $item) $actuals[] = $item->asXML(); if($expectedMatches != $actuals) { throw new PHPUnit_Framework_AssertionFailedError( - "Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "\n\n" + "Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "'\n\n" . "Instead the following elements were found:\n'" . implode("'\n'", $actuals) . "'" ); }