I am new in Codeception trying to run a sample unit test in my Laravel framework but getting the following error:
[RuntimeException] Call to undefined method UnitTester::haveRecord
And following code I have tried to run using 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
The unit.suite.yml file format with Laravel5 module:
actor: UnitTester
modules:
enabled:
- Asserts
- Laravel5:
part: ORM
- \Helper\Unit