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