[英]Codeception Unit testing [RuntimeException] Call to undefined method UnitTester::haveRecord
I am new in Codeception trying to run a sample unit test in my Laravel framework but getting the following error: 我是Codeception的新手,试图在我的Laravel框架中运行示例单元测试,但收到以下错误:
[RuntimeException] Call to undefined method UnitTester::haveRecord
And following code I have tried to run using Codeception: 以下代码我尝试使用Codeception运行:
<?php namespace Article;
use App\Article;
use Faker\Factory as Faker;
use Carbon\Carbon;
class SaveTest extends \Codeception\Test\Unit
{
/**
* @var \UnitTester
*/
protected $tester;
protected function _before()
{
}
protected function _after()
{
}
// tests
public function testSomeFeature()
{
$faker= Faker::create('App/Article');
$title = $faker->sentence;
$content = implode($faker->paragraphs(5));
$created_at = Carbon::now();
$updated_at = Carbon::now();
$this->tester->haveRecord( 'Article', ['title' => $title, 'content' => $content,'created_at' => $created_at,'updated_at' => $updated_at]);
$this->tester->seeRecord('articles',['title' => $title,'content' => $content,'created_at' => $created_at,'updated_at' => $updated_at]);
}
}
Could please help me out of this error? 可以帮我解决这个错误吗? Thanks in advance.
提前致谢。
The issue resolved after I have enabled Laravel5 module in unit.suite.yml 在unit.suite.yml中启用Laravel5模块后,问题解决了
The unit.suite.yml file format with Laravel5 module: Laravel5模块的unit.suite.yml文件格式:
actor: UnitTester
modules:
enabled:
- Asserts
- Laravel5:
part: ORM
- \Helper\Unit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.