sebastianbergmann / dbunit

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

Feature request: Adjustable column widths in table diff output #213

Open h3xx opened 6 years ago

h3xx commented 6 years ago

Current table diff output is set to 20 characters. All I want is a way to adjust this width.

Specific use case:

Pulling time stamps out of a PostgreSQL database puts them in the following format:

TIMESTAMP WITH TIME ZONE(6)        2018-06-27 10:05:09.647832-05
TIMESTAMP WITH TIME ZONE(0)        2018-01-01 00:00:00-06

Many times I use assertDataSetsEqual to compare data with time stamps. Often, the engineer responsible for the code will not have taken into account the database's time zone, and as such the test data will be an hour off. In this case, the table diff will not generate useful output:

Failed asserting that
+---------------------------+
| foo                       |
+---------------------------+
|            col            |
+---------------------------+
|  2018-06-27 16:58:23-09   |
+---------------------------+

 is equal to expected (table diff enabled)
+---------------------------+
| foo                       |
+---------------------------+
|            col            |
+---------------------------+
| '2018-06-27 15:58:23' !=  |
+---------------------------+

If the columns were adjustable somehow it would be easier to get useful test output, but they're not adjustable.

The "hack" I implemented locally is to pass in the column width via environment variable and just reference $_ENV inside AbstractTable - but I'm sure you could come up with something much better.

stale[bot] commented 5 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.