Php Codeception单元测试[RuntimeException]调用未定义的方法UnitTester::haveRecord
我是Codeception新手,尝试在我的Laravel框架中运行一个示例单元测试,但出现以下错误:Php Codeception单元测试[RuntimeException]调用未定义的方法UnitTester::haveRecord,php,laravel,unit-testing,laravel-5.2,codeception,Php,Laravel,Unit Testing,Laravel 5.2,Codeception,我是Codeception新手,尝试在我的Laravel框架中运行一个示例单元测试,但出现以下错误: [RuntimeException] Call to undefined method UnitTester::haveRecord 我尝试使用Codeception运行以下代码: <?php namespace Article; use App\Article; use Faker\Factory as Faker; use Carbon\Carbon; class Save
[RuntimeException] Call to undefined method UnitTester::haveRecord
我尝试使用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]);
}
}
在启用unit.suite.yml中的Laravel5模块后,问题得到解决
带有Laravel5模块的unit.suite.yml文件格式:
actor: UnitTester
modules:
enabled:
- Asserts
- Laravel5:
part: ORM
- \Helper\Unit
您是否在unit.suite.yml中启用了Laravel5模块?在您的问题解决后,该模块未启用。谢谢。