toBeEmpty(); DB::rollBack(); expect($events)->toBeEmpty(); DB::beginTransaction(); Event::dispatch(new OperationCompleted('server-uuid', 'backup', false, 'backup-uuid')); expect($events)->toBeEmpty(); DB::commit(); expect($events)->toHaveCount(1); expect($events[0]->serverUuid)->toBe('server-uuid'); expect($events[0]->successful)->toBeFalse(); expect($events[0]->resourceUuid)->toBe('backup-uuid'); } finally { while (DB::transactionLevel() > $depth) { DB::rollBack(); } Event::forget(OperationCompleted::class); } });