mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-04 04:48:30 +00:00
143 - Testing Events
This commit is contained in:
@@ -6,7 +6,9 @@ use App\User;
|
||||
use App\Concert;
|
||||
use Carbon\Carbon;
|
||||
use Tests\TestCase;
|
||||
use App\Events\ConcertAdded;
|
||||
use Illuminate\Http\Testing\File;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
@@ -460,4 +462,20 @@ class AddConcertTest extends TestCase
|
||||
$this->assertNull($concert->poster_image_path);
|
||||
});
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function an_event_is_fired_when_a_concert_is_added()
|
||||
{
|
||||
$this->disableExceptionHandling();
|
||||
|
||||
Event::fake([ConcertAdded::class]);
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->post('/backstage/concerts', $this->validParams());
|
||||
|
||||
Event::assertDispatched(ConcertAdded::class, function ($event) {
|
||||
$concert = Concert::firstOrFail();
|
||||
return $event->concert->is($concert);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user