Renames ManagedEnvironment context badge to Environment context as requested. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #431
60 lines
1.9 KiB
PHP
60 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Services\OperationRunService;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Queue;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
class Spec360DispatchContextProbeJob implements ShouldQueue
|
|
{
|
|
use Dispatchable;
|
|
use InteractsWithQueue;
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
public function __construct(public int $operationRunId) {}
|
|
|
|
public function handle(): void {}
|
|
}
|
|
|
|
it('records canonical dispatch metadata without inventing queue job ids in Spec360', function (): void {
|
|
Queue::fake();
|
|
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
|
|
$run = app(OperationRunService::class)->ensureRun(
|
|
tenant: $tenant,
|
|
type: 'environment.review.compose',
|
|
inputs: ['fingerprint' => 'spec360-dispatch'],
|
|
initiator: $user,
|
|
);
|
|
|
|
app(OperationRunService::class)->dispatchOrFail(
|
|
$run,
|
|
fn () => Spec360DispatchContextProbeJob::dispatch((int) $run->getKey())
|
|
->onConnection('database')
|
|
->onQueue('operations'),
|
|
);
|
|
|
|
$dispatch = (array) data_get($run->fresh()->context, 'dispatch', []);
|
|
|
|
expect($dispatch)->toMatchArray([
|
|
'job_class' => Spec360DispatchContextProbeJob::class,
|
|
'queue' => 'operations',
|
|
'connection' => 'database',
|
|
'correlation_version' => 1,
|
|
'operation_run_id' => (int) $run->getKey(),
|
|
])->and($dispatch['dispatched_at'] ?? null)->toBeString()
|
|
->and(array_key_exists('job_id', $dispatch))->toBeFalse();
|
|
|
|
Queue::assertPushed(Spec360DispatchContextProbeJob::class, fn (Spec360DispatchContextProbeJob $job): bool => $job->operationRunId === (int) $run->getKey());
|
|
});
|