Test for commands

I’m trying to write a test for a command line class that extends CConsoleCommand and lives in protected/commands

I’m encountering several problems, but the one that has me stumped is that fixtures do not seem to be loading. If I pause the test half way through and check the db, no fixtures have been loaded and if I try to access them using $this->fixtureName[‘columnName’] then it errors as not found.

I have added the necessary path into the config and I can access the run method of the command class.

Any ideas?


class NotifyStoresOfTransactionsCommandTest extends CTestCase


    public $fixtures=array(



	public function testRun()


		$tran_test = $this->transaction['test_transaction']; // fails

		// ...





Can anyone confirm if they have successfully written tests for command classes?

I did some testing. Seems like you need to extend from CDbTestCase for fixture handling.


Thanks Tommy, I didn’t think of that. Much appreciated.