TenantAtlas/apps/platform/tests/Feature/TenantConfiguration/Spec415CoverageCaptureOperationRunTest.php
ahmido ca0f54614d feat: add generic content-backed coverage capture (#482)
Automated PR provided by Codex via Gitea API.

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #482
2026-06-25 19:55:52 +00:00

32 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
use App\Jobs\TenantConfiguration\CaptureTenantConfigurationEvidenceJob;
use App\Models\ProviderConnection;
use App\Services\TenantConfiguration\StartTenantConfigurationCapture;
use App\Support\OperationRunStatus;
use Illuminate\Support\Facades\Queue;
it('reuses active capture runs and keeps queued context sanitized', function (): void {
Queue::fake();
[$user, $tenant] = createMinimalUserWithTenant(role: 'owner');
$connection = ProviderConnection::factory()->create([
'workspace_id' => (int) $tenant->workspace_id,
'managed_environment_id' => (int) $tenant->getKey(),
]);
$service = app(StartTenantConfigurationCapture::class);
$first = $service->start($tenant, $connection, $user, ['deviceAndAppManagementAssignmentFilter']);
$second = $service->start($tenant, $connection, $user, ['deviceAndAppManagementAssignmentFilter']);
expect($second->getKey())->toBe($first->getKey())
->and($first->status)->toBe(OperationRunStatus::Queued->value)
->and(json_encode($first->context, JSON_THROW_ON_ERROR))->not->toContain('client_secret')
->and(json_encode($first->context, JSON_THROW_ON_ERROR))->not->toContain('access_token');
Queue::assertPushed(CaptureTenantConfigurationEvidenceJob::class, 1);
});