I create fixture test as follow:
1:create fixture file
1)add a new file in tests/fixtures/tbl_project.php
2)add an array to it:
return array(
'project1' => array(
'name' => 'Test Project 1',
'description' => 'This is test project 1',
'create_time' => '',
'create_user_id' => '',
'update_time' => '',
'update_user_id' => '',
),
)
...
3)and I configure config/test.php
return CMap::mergeArray(
require(dirname(__FILE__).'/main.php'),
array(
'components'=>array(
'fixture'=>array(
'class'=>'system.test.CDbFixtureManager',
),
/* uncomment the following to provide test database connection
'db'=>array(
'connectionString'=>'DSN for test database',
),
*/
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=trackstar_test',
'emulatePrepare' => true,
'username' => 'root',
'password' => '********',
'charset' => 'utf8',
),
),
)
);
4):declear in my ProjectTest.php
class ProjectTest extends CDbTestCase{
public $fixtures = array(
'projects' => 'Project',
);
}
but I use phpunit to test a assert :
$this->assertTrue($this->projects('project1') instanceof Project);
the phpunit output like:
- ProjectTest::testCreate
Invalid argument supplied for foreach()
D:\xampp\xampp\htdocs\yii6\framework\test\CDbFixtureManager.php:168
D:\xampp\xampp\htdocs\yii6\framework\test\CDbFixtureManager.php:122
D:\xampp\xampp\htdocs\yii6\framework\test\CDbFixtureManager.php:85
D:\xampp\xampp\htdocs\yii6\framework\base\CModule.php:372
D:\xampp\xampp\htdocs\yii6\framework\test\CDbTestCase.php:84
D:\xampp\xampp\htdocs\yii6\framework\test\CDbTestCase.php:116
why ?