我真的被这个验收测试困住了。
我的代码是这样的
$I->click('Submit');
$I->see('Client Added');
$I->seeInDatabase('customers',[
'afm'=>'111'
]);
一切都会过去,直到“seeInDatabase”行为止。日志给我这个错误“警报:找不到匹配的记录,断言‘0’大于 0 失败。”。
我检查了数据库设置
modules:
config:
Db:
dsn: 'mysql:host=localhost;dbname=dbtesting'
user: 'test'
password: 'test'
dump: app/tests/_data/dump.sql
populate: true
cleanup: true
我觉得不错。我用 seeInDatabase() 仔细检查了一行,我知道它在那里,是的,它工作得很好。 (不是 PDO 问题或类似的问题)
因此,我在表单的“POST”之后强制在 Controller 中进行创建,以确保
public function store(){
\Customer::create(['afm'=>111]);
return \Redirect::route('customers.index')->with('successMsg',Client Added');
}
我再次无法验证这个新行。知道如何解决这个问题吗?
////更新/////
当我用普通 PDO 代码替换 Eloquent Insert 时,一切正常。如何解决这个问题? (完整信息here)
最佳答案
我刚刚遇到了同样的问题,显然我们在 Laravel4 模块中提供了“seeRecord”辅助方法来检查记录。就像魅力一样。
$I->seeRecord('customers', ['afm' => '111']);
关于laravel - Codeception seeInDatabase() 对我不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22492531/