I have some PHPUnit test classes which use fixtures. I have for 10 tables fixtures defined. Directory structure:
tests
fixtures
table1.php
...
table10.php
unit
MyTestClass.php
I now have a test class (MyTestClass.php
), in which I only want to populate 2 of these tables. I have the following code in that class.
class BaseACAExportTest extends CDbTestCase
{
public $fixtures = array(
'table1' => 'Model1',
'table2' => 'Model2'
);
public function setUp()
{
// Call the parent setUp to set up the fixtures
parent::setUp();
die();
}
public testMe()
{
// Test here
}
}
The function TruncateDatabase
is a custom-made helper function which truncates all 10 tables. I have verified that this function works. I run the tests and I inspect after the die
statement the database. In it, I see all 10 tables, instead of only the two tables that I have defined in fixtures
. Why does it populate all tables defined in the directory fixtures
? Is there a way to circumvent this?