loadXML('' . "" . "$t_result"); $document2 = new DOMDocument(); $doc_output = $document2->loadXML('' . "" . "$t_output"); if ($doc_result) { static::normalizeElementContent($document->documentElement, false); $n_result = $document->saveXML(); } else { $n_result = '--- Expected Result: XML Parse Error ---'; } if ($doc_output) { static::normalizeElementContent($document2->documentElement, false); $n_output = $document2->saveXML(); } else { $n_output = '--- Output: XML Parse Error ---'; } } else { // '@' suppressors used because some tests have invalid HTML (multiple elements with the same id attribute) // Perhaps isolate to a separate test and remove this? $document = new DOMDocument(); $doc_result = @$document->loadHTML($t_result); $document2 = new DOMDocument(); $doc_output = @$document2->loadHTML($t_output); if ($doc_result) { static::normalizeElementContent($document->documentElement, false); $n_result = $document->saveHTML(); } else { $n_result = '--- Expected Result: HTML Parse Error ---'; } if ($doc_output) { static::normalizeElementContent($document2->documentElement, false); $n_output = $document2->saveHTML(); } else { $n_output = '--- Output: HTML Parse Error ---'; } } $n_result = preg_replace('{^.*?|.*?$}is', '', $n_result); $n_output = preg_replace('{^.*?|.*?$}is', '', $n_output); $c_result = $n_result; $c_output = $n_output; $c_result = trim($c_result) . "\n"; $c_output = trim($c_output) . "\n"; // This will throw a test exception if the strings don't exactly match TestCase::assertSame($c_result, $c_output, $message); } /** * @param DOMElement $element Modifies this element by reference * @param bool $whitespace_preserve Preserve Whitespace * @return void */ protected static function normalizeElementContent($element, $whitespace_preserve) { # # Normalize content of HTML DOM $element. The $whitespace_preserve # argument indicates that whitespace is significant and shouldn't be # normalized; it should be used for the content of certain elements like #
 or