TenantAtlas/tests/Unit/BulkOperationRunProgressTest.php
Ahmed Darrazi de199ef476 fix(tests): remove per-file TestCase uses
Pest v4 discovery fails when unit tests re-bind the test case with uses(TestCase::class). Remove per-file bindings and keep RefreshDatabase where needed. Also update RunBackupScheduleJobTest to pass BulkOperationService when calling handle() manually.
2026-01-08 01:38:54 +01:00

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);
});