sebastianbergmann / dbunit

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

Change array_merge to array_replace in order to permit numeric keys #135

Closed jchamberlain closed 10 years ago

jchamberlain commented 10 years ago

It's an edge case, but I've got a particular scenario where I'm using integers for column names in a database table. I need to make sure the table is being populated correctly, so as normal I create one dataset from the database and one from a file, then get the tables and use $this->assertTablesEqual(). The problem is that DefaultTable::addRow() incorrectly sets the value of all columns with integer names to NULL. It happens to both real and expected datasets, so regardless of actual values in those columns, the tests always pass.

The problem occurs due to the use of array_merge(), which overwrites NULL values where keys are strings, but does not if keys are numeric. I've changed that to array_replace(), which I believe is the desired behavior to begin with, and which causes all my tests to work again.

elazar commented 10 years ago

Thanks!