I am trying to use PHPUnit/DBUnit to test my Zend Framework DbTable models. I am getting tripped up with tables that have a timestamp.
I am trying to use assertDataSetsEqual to compare an the actual results of an insert to the expected results. Of course, when I insert a record into a table with a timestamp, the timestamp field get populated with the current date/time. The dataset that represents the expected data is static so the timestamp won’t match.
How can I handle this situation? Can I make the assertion ignore the timestamp column?
I just found a much better solution to this thanks to this blog post.
I created a function to allow me to easily assert my two datasets are equal.
And a private function to return the filtered dataset.
Now to compare two datasets while excluding any columns I just do this.
This makes for a much easier/cleaner way to test models that correspond to tables with a timestamp column.