I'm using PHP Unit to create a Unit test for a store function that stores data in a database.
Currently, i have a test verifies that it has stored data.
However, I also want to create a test that proves that a laravel log message has been produced if the model save function fails.
The code below shows the store function. The "log::info" is the line I want to test.
Thanks.
public function store(Venue $venue)
{
$saved = $venue->save();
if($saved == false)
{
Log::info('Failed to Save Venue'. $venue);
}
}
This what I have so far, i pass an empty model that will cause the save to fail due to database constraints
public function test_venue_store_failed()
{
$venue = new Venue();
$venueRepo = new VenueRepository();
$this->withExceptionHandling();
$venueRepo->store($venue);
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2zpaYKy
via IFTTT
Aucun commentaire:
Enregistrer un commentaire