2

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 :(

1 Answer 1

8

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().

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I've been banging my head against the wall for hours due to this!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.