What Changed Removed per-file uses(TestCase::class ...) bindings in Unit tests to avoid Pest v4 “folder already uses the test case” discovery failure (kept RefreshDatabase where needed). Updated the backup scheduling job test to pass the newly required BulkOperationService when manually calling RunBackupScheduleJob::handle(). Where Unit (bulk cleanup across 56 files) RunBackupScheduleJobTest.php Verification ./vendor/bin/sail test → 443 passed, 5 skipped Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local> Reviewed-on: #45
32 lines
932 B
PHP
32 lines
932 B
PHP
<?php
|
|
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
use App\Services\BulkOperationService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
test('bulk operation service updates progress counters', function () {
|
|
$tenant = Tenant::factory()->create();
|
|
$user = User::factory()->create();
|
|
|
|
$service = app(BulkOperationService::class);
|
|
$run = $service->createRun($tenant, $user, 'policy', 'delete', [1, 2, 3], 3);
|
|
|
|
$service->start($run);
|
|
|
|
$service->recordSuccess($run);
|
|
$service->recordSkipped($run);
|
|
$service->recordFailure($run, '3', 'Test failure');
|
|
|
|
$run->refresh();
|
|
|
|
expect($run->status)->toBe('running')
|
|
->and($run->processed_items)->toBe(3)
|
|
->and($run->succeeded)->toBe(1)
|
|
->and($run->skipped)->toBe(1)
|
|
->and($run->failed)->toBe(1)
|
|
->and($run->failures)->toBeArray()
|
|
->and($run->failures)->toHaveCount(1);
|
|
});
|