Exception : Unknown property 'posts' for class 'PostTest'.
protected/tests/unit/PostTest.php
class PostTest extends CDbTestCase
{
public $fixtures=array('posts' => 'Post');
public function testCreate()
{
/**
* @var Post $model
*/
$model = $this->posts['sample1'];
$this->assertTrue($model->save(false));
$post=Post::model()->findByPk($model->id);
$this->assertTrue($post instanceof Post);
}
}protected/tests/fixtures/Post.php
return array( 'sample1'=>array( 'title'=>'Тестовый заголовок', 'content'=>'Тестовый текст', 'status' => 2, 'author_id'=>1, ), );
В модели Post:
public function tableName()
{
return 'tbl_post';
}protected/config/test.php
array(
'components'=>array(
'fixture'=>array(
'class'=>'system.test.CDbFixtureManager',
'basePath'=>dirname(__FILE__).'/../tests/fixtures',
), ...
),
)

Help











