Wednesday, September 5. 2007Adding Database Tests to Existing PHPUnit Test CasesTrackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
Hi, I was playing with the extension from the svn and wondered if there is a possibility to limit the columns in a table I want to compare. For example in many cases I'm not interested to check the id column.
Yes, this is in fact possible utilizing the PHPUnit_Extensions_DBUnit_DataSet_DataSetFilter decorator.
You basically pass an instantiated dataset object to this class' constructor as the first parameter and then you pass an associative array keyed on table names and the values are an array of columns to ignore. In otherwords, something like this: $databaseDataSet = $this->getConnection->createDataSet(); $filteredDataSet = new PHPUnit_Extensions_DBUnit_DataSet_DataSetFilter($databaseDataSet, array( 'messages' => array('created', 'last_modified') )); You can also do it at the table level. $filteredTable = new PHPUnit_Extensons_DBUnit_DataSet_TableFilter($messagesTable, array('created', 'last_modified')); Hope that helps
Thank you for the fast response, Mike. The extension works very nice. I love it! Can't wait for PHPUnit 3.2 stable to be able to use it in production environment.
You said
"Yes, this is in fact possible utilizing the PHPUnit_Extensions_DBUnit_DataSet_DataSetFilter decorator" In my 3.2.21 setting I have to use PHPUnit_Extensions_Database_DataSet_DataSetFilter class instead
Has this functionality been moved, removed, renamed?
I keep getting undefined method errors. I poked around in Framework/TestCase.php and saw no mention of the PHPUnit_Extensions_Database_DefaultTester method. Thanks.
Hi Mark,
Great extension! I've noticed that you used to work on the official documentation of this feature (http://www.phpunit.de/pocket_guide/3.2/en/database.html). However, it hasn't been updated in last 6 months. Any chance you will find some time to finish it? Cheers.
I had the problem that loading the database with contents from an XML file was horribly slow (took more than a minute per test case on my setup!) even though there are just a dozen tables in the file with a handful of rows in each.
PHPUnit_Extensions_Database_Operation_RowBased is the bottle neck. I got it to speed up by a factor of almost 40 by changing to transactions and most importantly by replacing $databaseTableMetaData = $databaseDataSet->getTableMetaData($table->getTableMetaData()->getTableName()); with: $databaseTableMetaData = $table->getTableMetaData();
PHPUnit_Extensions_Database_Operation_RowBased::execute() is the bottle neck to be precise.
The extension works very nice. I love it! Can't wait for PHPUnit 3.2 stable to be able to use it in production environment.
You are always trying your best. I think you can finish it successfully.
|
Paying for the Site
QuicksearchCategoriesArchivesDaily ReadsThe PHP WTF Sebastian Bergmann Wez Furlong Tom Sommer Tobias Schlitt Chris Shiflett Ben Ramsey adam trachtenberg Sklar george schlossnagle Dynamically Typed (Harry Fuecks) John Coggeshall John Lim Marco Tabini PHP Application Tools Planet PHP PHPCommunity.org |

