23 lines
748 B
PHP
23 lines
748 B
PHP
<?php
|
|
|
|
use App\Models\MasterImage;
|
|
use App\Models\Reservation;
|
|
use Illuminate\Support\Facades\Bus;
|
|
|
|
it('charges and confirms a reservation and dispatches composite job', function () {
|
|
MasterImage::create(['path' => 'master.png', 'version' => 1]);
|
|
|
|
$res = Reservation::create(['x' => 0, 'y' => 0, 'w' => 2, 'h' => 2, 'status' => 'held', 'reserved_until' => now()->addMinutes(5)]);
|
|
|
|
Bus::fake();
|
|
|
|
$response = $this->postJson('/api/payment/charge', ['reservation_id' => $res->id]);
|
|
$response->assertSuccessful();
|
|
|
|
expect(Reservation::find($res->id)->status)->toBe('confirmed');
|
|
|
|
Bus::assertDispatched(App\Jobs\CompositeImage::class, function ($job) use ($res) {
|
|
return $job->reservationId === $res->id;
|
|
});
|
|
});
|