php/dbunit错误,当在表中为空 我得到和错误测试存储过程或查询包含或返回一个NULL值时,我已经尝试了同样的例子doest返回任何NULL值和它的作品完美,我怎么能代表NULL在XML文件来测试它php/dbunit错误,当在表中为空
试验规程
public function StarRead()
{
fwrite(STDOUT, __METHOD__ . " Check with valid data \n");
$resultTable = $this->getConnection()->createQueryTable(
'Star', 'CALL get_star(1,NULL,0,2)'
);
$expected = $this->createFlatXMLDataSet(dirname(__FILE__).'/_files/new.xml');
$expectedTable = $expected->getTable('Star');
//Here we check that the table in the database matches the data in the XML file
$this->assertTablesEqual($expectedTable, $resultTable);
}
XML文件
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
<Star
productId ="4"
currentPrice =""
listPrice =""
createdOn ="2012-12-12 12:12:12"
originalImage ="link"
merchantName =""
title ="Christopher Knight H"
url ="link"
/>
</dataset>
输出:
PHPUnit 4.0.12 by Sebastian Bergmann.
DBTest::StarRead Check with valid data F
Time: 1.4 seconds, Memory: 8.50Mb
There was 1 failure:
1) DBTest::StarRead Failed asserting that +----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ | AutoStar | +----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ | productId | currentPrice | listPrice | createdOn | originalImage | merchantName | title | url | +----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ | 4 | NULL | NULL | 2012-12-12 12:12:12 | link | NULL | Christopher Knight H | link | +----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
is equal to expected (table diff enabled) +----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ | AutoStar | +----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ | productId | currentPrice | listPrice | createdOn | originalImage | merchantName | title | url | +----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ | 4 | | | 2012-12-12 12:12:12 | link | | Christopher Knight H | link | +----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
.
FAILURES! Tests: 1, Assertions: 1, Failures: 1.
我在Ubuntu 12.04 LTS(phpunit 3.7.28)中尝试了相同的代码,它工作正常。
而在Debian 6.0.8(phpunit 4.0.12)中,它给了我同样的错误。为什么是这样?
只是胡乱猜测,如果从XML文件中删除了“”行会发生什么?毕竟,“”与NULL完全不同。 – Jasper
得到一个错误 的RuntimeException:AttValue:“或”预期 属性构建错误 找不到开始标记结束 – Terence
感谢您的答复真的意味着很多对我的感谢 – Terence