Skip to content
This repository was archived by the owner on Apr 12, 2018. It is now read-only.

DBUnit row ordering during data-table assertions #307

Closed
arunjusrut opened this issue Jun 15, 2015 · 1 comment
Closed

DBUnit row ordering during data-table assertions #307

arunjusrut opened this issue Jun 15, 2015 · 1 comment

Comments

@arunjusrut
Copy link

https://phpunit.de/manual/current/en/database.html#database.asserting-the-state-of-a-table

There is an issue in the example given, that does not reflect reality.
In the example, three throws are present in the database table. The expectation file contains those three rows as well, so that we can assert against the real table data. The query table is created using "SELECT * FROM guestbook".

Judging from the example, we would assume that asserting two data tables is done without regard to the order of the rows in any of the two data tables. This does not seem to be the case, since my test fails randomly (succeeding at other times), even though the data in database is exactly equal to my expectation file.

The problem, i believe, is the fact that most databases will not return rows in any predictable order, unless an order by clause is explicitly used. So, in short, my expectation records are in a fixed order, while my database returns a result set in no specific order, and DBUnit is sensitive to order when assertions are made.

I cannot seem to understand if this is a bug in dbunit, the documentation is not up-to-date or if i am missing something here. In any case, i have had to used certain hacks (like keeping autoincrements fields to ensure ordering of inserts in database) so that my tests work as expected.

@sebastianbergmann
Copy link
Owner

Dear contributor,

thanks to the hard work by @belanur, @starikovm, @trueromio, and others, the changes outlined in #471 (comment) have been implemented.

This repository, https://github.com/sebastianbergmann/phpunit-documentation, is now archived and read-only. The documentation for PHPUnit version prior to PHPUnit 7.0 will no longer be changed or updated. It is still hosted at

  • Multiple HTML files: https://phpunit.de/manual/6.5/en/index.html
  • Multiple HTML files (in a .tar.bz2 archive): https://phpunit.de/manual/current/en/download.tar.bz2
  • Single HTML file: https://phpunit.de/manual/current/en/phpunit-book.html
  • PDF: https://phpunit.de/manual/current/en/phpunit-book.pdf
  • ePub: https://phpunit.de/manual/current/en/phpunit-book.epub

Simply replace 6.5 with the version number you are looking for. Simply replace en with fr, pt_br, ja, or zh_cn to access the French, Brazilian Portuguese, Japanese, or Simplified Chinese translation, respectively.

Starting with the documentation for PHPUnit 7.0, the PHPUnit documentation is hosted at https://phpunit.readthedocs.io/.

I am sorry that I have to close this issue here as GitHub does not support moving issues from one project to another. Please open a new ticket for this issue in one of the new issue trackers (see above).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants