sebastianbergmann / dbunit

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

assertTablesEqual() relies on column order #129

Closed denilsonsa closed 6 years ago

denilsonsa commented 10 years ago

My use-case:

// Get the dataset directly from the database.
$actual = $this->getConnection()->createDataSet();
// Get the dataset from a XML file.
$expected = $this->createXMLDataSet('foobar.xml');
$this->assertTablesEqual(
    $actual->getTable('foobar'),
    $expected->getTable('foobar'));

The output:

Failed asserting that 
+----------------------+----------------------+
| foobar                                      |
+----------------------+----------------------+
|         foo          |         bar          |
+----------------------+----------------------+
|          1           |          2           |
+----------------------+----------------------+
is equal to expected 
+----------------------+----------------------+
| foobar                                      |
+----------------------+----------------------+
|         bar          |         foo          |
+----------------------+----------------------+
|          2           |          1           |
+----------------------+----------------------+

Both tables are exactly the same, but the column order is different (maybe because the column order in the XML file is different than the column order from SHOW CREATE TABLE foobar;).

Relying on column order makes the test much more fragile (fails when it shouldn't), and requires a extra work to keep those tests passing.

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.