'tenant-1', 'name' => 'Tenant One', 'metadata' => [], ]); $backupSet = BackupSet::create([ 'tenant_id' => $tenant->id, 'name' => 'Backup', 'status' => 'completed', 'item_count' => 0, ]); $restoreRun = RestoreRun::create([ 'tenant_id' => $tenant->id, 'backup_set_id' => $backupSet->id, 'requested_by' => 'actor@example.com', 'is_dry_run' => false, 'status' => RestoreRunStatus::Queued->value, 'requested_items' => null, 'preview' => [], 'results' => null, 'metadata' => [], ]); $restoreService = $this->mock(RestoreService::class, function (MockInterface $mock) use ($tenant, $backupSet) { $mock->shouldReceive('executeForRun') ->once() ->withArgs(function (RestoreRun $run, Tenant $runTenant, BackupSet $runBackupSet, ?string $email, ?string $name) use ($tenant, $backupSet): bool { return $run->status === RestoreRunStatus::Running->value && $runTenant->is($tenant) && $runBackupSet->is($backupSet) && $email === 'actor@example.com' && $name === 'Actor'; }) ->andReturnUsing(function (RestoreRun $run): RestoreRun { $run->update([ 'status' => RestoreRunStatus::Completed->value, 'completed_at' => now(), ]); return $run->refresh(); }); }); $job = new ExecuteRestoreRunJob($restoreRun->id, 'actor@example.com', 'Actor'); $job->handle($restoreService, app(AuditLogger::class)); $restoreRun->refresh(); expect($restoreRun->started_at)->not->toBeNull(); expect($restoreRun->status)->toBe(RestoreRunStatus::Completed->value); });