Does anyone have a link to a good, working tutorial or book on how to get started with adding the DBUnit layer to my PHPUNit tests?
I've tried following the code in
protected function getDatabaseTester()
{
$pdo = new PDO('mysql:host=localhost;dbname=test', 'user', 'pass');
$connection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($pdo);
$tester = new PHPUnit_Extensions_Database_DefaultTester($connection);
$tester->setSetUpOperation(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT());
$tester->setTearDownOperation(PHPUnit_Extensions_Database_Operation_Factory::NONE());
/*
* the next line fails with the error
PHP Fatal error: __autoload(): Failed opening required 'PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet.php' (include_path= ***
*/
$tester->setDataSet(new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__).'/../../../files/xml_database_export.xml'));
return $tester;
}
The XML is created via mysqldump command. I'd happily use CSV, or even an array in memory (whatever works)
Unfortunately I just can't seem to get this system started.