我是
PHPUnit的新手,我在单元测试HTML输出方面遇到了一些麻烦.
我的测试如下:
/**
* @covers Scrap::removeTags
*
*/
public function testRemoveTags() {
// Variables
$simple_parameter = 'script';
$array_parameter = array('script', 'div');
$html = '
';// Expected HTML
$expected_html_whitout_script = new DOMDocument;
$expected_html_whitout_script->loadHTML('
');$expected_html_without_script_div = new DOMDocument;
$expected_html_without_script_div->loadHTML('
');// Actual HTML
$actual_whitout_script = new DOMDocument;
$actual_whitout_script->loadHTML($this->scrap->removeTags($html, $simple_parameter));
$actual_without_script_div = new DOMDocument;
$actual_without_script_div->loadHTML($this->scrap->removeTags($html, $array_parameter));
// Test
$this->assertEquals($expected_html_whitout_script, $actual_whitout_script);
$this->assertEquals($expected_html_without_script_div, $actual_without_script_div);
}
我的问题是DOMDocument对象生成一些HTML代码,我无法比较它.如何打印DOMDocument对象以查看输出?有关如何比较HTML的任何线索?
对不起,我的英语不好.
最好的祝福,