This is my testcase script:
public function testSave()
{
// write code here to test post saving method
Yii::app()->user->setId($this->posts['sample1']['author_id']);
$post = new Post;
$post->setAttributes($this->posts['sample1'], false);
$this->assertTrue($post->save(false));
$post = Post::model()->findByPk(1);
$this->assertTrue($post instanceof Post);
$this->assertEquals($this->posts('sample1'), $post);
}
i test, output these error(no init.php in fixtures folder):
Integrity constraint violation: 19 PRIMARY KEY must be unique
CDbFixtureManager will truncate corresponding table, why this eror occur.
error log:
2010/09/21 16:31:05 [error] [system.db.CDbCommand] Error in executing SQL: INSERT INTO 'tbl_post' ("title", "content", "status", "create_time", "update_time", "author_id", "tags", "id") VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7). Bind with parameter :yp0='测试帖子1', :yp1='This blog is powered by [Yii framework](http://www.yiiframework.com).', :yp2=2, :yp3=1285057865, :yp4=1285057865, :yp5=1, :yp6='yii, test_one', :yp7=1
In the insert sql statement: id = 1, this is one AUTOINCREMENT filed.(why not null)
I’m sorry my poor english。