I've created a database testing class for one of my modules. When I try to run a test case, the initial fixture is not set up - all the tables in the testing database are empty. Here is my getDataSet() method:
/**
* @return PHPUnit_Extensions_Database_DataSet_IDataSet
*/
public function getDataSet()
{
return $this->createFlatXMLDataSet(dirname(__FILE__).'/dataSets/initial.xml');
}
I found out that the getDataSet() method gets called, because when I create a syntax error in it, the test execution fails. But when I create errors in file initial.xml, nothing happens. It seems like the file initial.xml is not being parsed at all!
The path to the file should be OK, but I noticed that when I enter an invalid path, again, nothing happends. Apparently, method createFlatXMLDataSet() does not throw any exception when something is wrong. So now I don't have any clue of why it doesn't work :(
RESOLVED: It turned out that getDataSet() was not called, because I've overriden setUp() and didn't realize that I should call parent::setUp() from the overriden method body.
So the conclusion is: If you are overriding method setUp(), you always have to call parent::setUp().