assertXmlFileEqualsXmlFile()


assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile[, string $message = ''])

$actualFile 对应的 XML 文档与 $expectedFile 对应的 XML 文档不相同时报告错误,错误讯息由 $message 指定。

assertXmlFileNotEqualsXmlFile() 是与之相反的断言,接受相同的参数。


例 A.42: assertXmlFileEqualsXmlFile() 的用法

  1. <?php
  2. class XmlFileEqualsXmlFileTest extends PHPUnit_Framework_TestCase
  3. {
  4. public function testFailure()
  5. {
  6. $this->assertXmlFileEqualsXmlFile(
  7. '/home/sb/expected.xml', '/home/sb/actual.xml');
  8. }
  9. }
  10. ?>
  1. phpunit XmlFileEqualsXmlFileTest
  2. PHPUnit 4.8.0 by Sebastian Bergmann and contributors.
  3.  
  4. F
  5.  
  6. Time: 0 seconds, Memory: 5.25Mb
  7.  
  8. There was 1 failure:
  9.  
  10. 1) XmlFileEqualsXmlFileTest::testFailure
  11. Failed asserting that two DOM documents are equal.
  12. --- Expected
  13. +++ Actual
  14. @@ @@
  15. <?xml version="1.0"?>
  16. <foo>
  17. - <bar/>
  18. + <baz/>
  19. </foo>
  20.  
  21. /home/sb/XmlFileEqualsXmlFileTest.php:7
  22.  
  23. FAILURES!
  24. Tests: 1, Assertions: 3, Failures: 1.