I would like to test a route that is adding values to the DB.
Here is my test:
use DatabaseTransactions;
public function testValues()
{
$this->withoutMiddleware(); // Disabling the auth middleware
$response = $this->json('POST', '/values', [
'values' => 'THIS_IS_A_TEST',
]);
$response
->assertStatus(200);
$this->assertDatabaseHas('values', [
'value' => 'THIS_IS_A_TEST'
]);
}
The last assertion is always wrong because the database is empty. I think it's because the last assertion is done before the values are added to the DB.
Can I execute the second assertion only when the first one has been executed?
Or can I make this test work synchronously?
Aucun commentaire:
Enregistrer un commentaire