I created unit test, that should select * from Project table and that selection should be exactly one row, which I’ll compare with fixture. Purpose is to verify DB connection and illustrate testing.
Here’s the class:
class ApplicationTest extends CDbTestCase
{
public $fixtures=array(
'projects'=>':Project',
);
public function testSelect()
{
$command = Yii::app()->db->createCommand('SELECT * FROM Project');
$result = $command->query();
$this->assertEquals($this->projects['row1'], $result);
}
}
Here’s the command I’m running:
First 2 lines translated into English:
That message does not actually matte, it’s some bug that appear all the time.
But CTestCase is not found for some reason… Any ideas why?
Also, if I run phpunit unit\ApplicationTest.php without bootstrap key I get error:
That’s strange. It works fine here (also Windows).
As you may notice, there is a file demos/blog/protected/tests/bootstrap.php. This is the file that is automatically loaded when you run tests under that folder. In this file, yiit.php is included which further imports all necessary class files including CTestCase.php.