sebastianbergmann / dbunit

DbUnit port for PHP/PHPUnit.
https://phpunit.de/
Other
225 stars 186 forks source link

PHUNIT DBUNIT error for NULL in XML #128

Closed moses-gangipogu closed 10 years ago

moses-gangipogu commented 10 years ago

I get and error when test a stored procedure or query which contains or return a NULL values in it, i have tried the same example which doest return any NULL value and it WORKS perfect , how can i represent NULL in XML file to test it

TEST CODE

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 FILE

     <?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>

OUTPUT:

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.

moses-gangipogu commented 10 years ago

got it thanks http://phpunit.de/manual/3.7/en/database.html#database.how-to-handle-null-with-flat-xml-csv-datasets :thumbsup: