I'm keep getting the following error when using laravel's assertDatabaseHas() method in my tests.
Error: Call to undefined method Illuminate\Http\Response::assertDatabaseHas()
this is my code fragment using assertDatabaseHas() :
$response = $this->withSession(['user_id' => $this->user_id])
->json('post',
route('some_route'),
$request //an array
);
$request['myuser_id'] = $this->user_id;
$response->assertStatus($expected['code'])
->assertDatabaseHas('profiles',$request);
}
I also tried to use $this->assertDatabaseHas(), but a new error appeared:
TypeError: Argument 2 passed to PHPUnit\Framework\Assert::assertThat() must be an instance of PHPUnit\Framework\Constraint\Constraint, instance of Illuminate\Foundation\Testing\Constraints\HasInDatabase given, called in /project_path/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php on line 22
I searched for a while for the problem's solution and found this one : solution , but downgrading phpunit version to 5.* didn't work for me.
I'm using laravel 5.5 and phpunit 6.5.5 .
any idea guys?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2KBucNA
via IFTTT
Aucun commentaire:
Enregistrer un commentaire