CDbTestCase sub class problem

I though I would create a CDbTestCase sub class to put code for fixing logging problems and for changing fixtures directory easily:




class DbTestCase extends CDbTestCase

{	

	// Fixtures sub directory to use

	public $directory='';


	public function setUp()

	{

		// Change fixtures directory for all tests

		$fixtureManager=$this->getFixtureManager();

		$fixtureManager->basePath.=$this->directory;

	}


	public static function tearDownAfterClass()

	{

		// Fix for logging not working in tests

		Yii::app()->onEndRequest(new CEvent(null));

	}

}



But since doing this I have noticed some problems:

  1. DbTestCase->fixtures can no longer be used to load fixtures.

  2. All fixtures are always loaded anyway, is this right?

EDIT:

I have also now added a setFixtures() method to my DbTestCase class:




class DbTestCase extends CDbTestCase

{	

	...

	public function setFixtures($fixtures)

	{

		// Set fixtures array

		$this->fixtures=$fixtures;

	}

	...

}



And calling it from my test class:




class ModelTest extends DbTestCase

{

	public function setUp()

	{

		$this->setFixtures(array(

			'name'=>'Model'

		));

		

		parent::setUp();

	}

}



But this doesn’t help either.

Problem solved:




class DbTestCase extends CDbTestCase

{	

	// Fixtures sub directory to use

	public $directory='';


	public function __construct($name=null,array $data=array(),$dataName='')

	{

		parent::__construct($name,$data,$dataName);

		$this->init();

	}


	public function init()

	{

		// Change fixtures directory for all tests

		$fixtureManager=$this->getFixtureManager();

		$fixtureManager->basePath.=$this->directory;

	}


	public static function tearDownAfterClass()

	{

		// Fix for logging not working in tests

		Yii::app()->onEndRequest(new CEvent(null));

	}

}



And:




class ModelTest extends DbTestCase

{	

	public function init()

	{

		$this->fixtures=array(

			'name'=>'Model'

		);


		parent::init();

	}


	public function testAModelMethod()

	{


	}

}