sebastianbergmann / dbunit

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

Booleans also must be treated in a special way #136

Closed zerkms closed 6 years ago

zerkms commented 10 years ago

In another pull request it was added a special case for comparing numeric values: https://github.com/sebastianbergmann/dbunit/commit/94e8237bb516889164b40a22da13aaa0c88a0c9f#diff-ff8d2de4c53f9d6000d6c4dbb9c90c34R167

But the thing is that database driver (PDO pgsql in my case) might also return booleans.

And since there is no way to specify a boolean value in a fixture file (they all are treated as strings) - the comparison $thisValue !== $otherValue is always evaluated to false.

atulkulk commented 10 years ago

I am also facing with the same issue. Unit tests are failing because of the new implementation.

sooners87 commented 10 years ago

I am having the same issue in the latest phpunit. In phpunit 3.7.28 its ignoring type for comparison. But its doing type check now.

Using createQueryTable to get the data from db and using PHPUnit_Extensions_Database_DataSet_XMLDataSet to get data from xml file. The one from DB returns with the correct type, but one from xml, all are strings. So when using $this->assertThat it fails.

elazar commented 10 years ago

Related: #107

zerkms commented 10 years ago

My proposal: to use xml namespaces to express the data type so that DataSet class might convert it explicitly.

Examples:

bool:foo="true"
bool:foo="1"
bool:foo="no"

int:bar="42"

If dbunit dev team is interested - I might allocate some time to it and implement.

hairmare commented 7 years ago

I ended up migrating to yml datasets since src/DataSet/XmlDataSet.php#L67 still contains its (string) casting magic.

PeteDevoy commented 7 years ago

I changed to YAML after hairmare's suggestion but was still experiencing problems with PostgresSQL, eventually having to use PostgresSQL standard which is effectively a one char string in YAML, e.g.

name: "Michael Moore"
filmmaker: t
athletic: f    

Edit: Disregard that, same thing fails elsewhere.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had activity within the last 60 days. It will be closed after 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 6 years ago

This issue has been automatically closed because it has not had activity since it was marked as stale. Thank you for your contributions.