Reputation: 626
Making a test for database with Laravel (8.44.0) assetion assertModelExists(), fails on an error.
Error : Call to undefined method Tests\Feature\CommuneTest::assertModelExists()
The test class looks like this
<?php
namespace Tests\Feature;
use App\Models\Commune;
use Illuminate\Foundation\Testing\Concerns\InteractsWithDatabase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class CommuneTest extends TestCase
{
use RefreshDatabase, InteractsWithDatabase;
/**
* Test can save a commune model on DB
*
* @return void
* @test
*/
public function canStoreDb()
{
$commune = Commune::factory()->create();
$this->assertModelExists($commune);
}
}
What do you think is missing?
Upvotes: 0
Views: 461
Reputation: 28911
The assertModelExists
method was added September 2021:
https://github.com/laravel/framework/pull/38766
Version 8.44.0 was released May 2021:
https://github.com/laravel/framework/releases/tag/v8.44.0
So just update Laravel to the latest 8.x release and you should be good to go.
Upvotes: 2