[Solved]Yii's Fixture Can't Use with setUp() and tearDown()

class SalesTest extends CDbTestCase {

	private $object;

	public $fixtures = array('stock' => 'Stock', 'sales'=>'Sales');

	protected function setUp() {

		$this->object = new Sales;



	protected function tearDown() {



public function testTransact_Normal_ReturnEquals() {


		$model = $this->sales('sales1');

		$stock =$this->stock('stok2');






		$this->assertEquals(90, $stock->qty);


I got this error:


Exception: Unknown method ‘sales’ for class ‘SalesTest’.

If I remove setUp() and tearDown() no error, but I really do hope can put setUp() and tearDown().

So what is the workaround to use fixtures and setUp()/tearDown() ?

try calling parent::setUp() in your setUp method…

protected function setUp()



    $this->object = new Sales


wow, it’s work! Thanks wk :)

Lol 2 hours of searching and I find this topic AFTER I figured this out :P Ohh well, I can truthfully say I’ve learned the material now ;)