You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.2 KiB
PHP
66 lines
2.2 KiB
PHP
<?php
|
|
|
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
|
|
|
use App\Models\CloudJob;
|
|
use App\Services\Cloud\CloudJobService;
|
|
|
|
$assert = static function (bool $condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
$job = static function (array $overrides = []): CloudJob {
|
|
$now = time();
|
|
$model = new CloudJob();
|
|
$model->setRawAttributes(array_replace([
|
|
'id' => 91,
|
|
'operation_id' => '11111111111111111111111111111111',
|
|
'kind' => 'action',
|
|
'phase' => 'terminal',
|
|
'outcome' => 'failed',
|
|
'status' => 'failed',
|
|
'error_code' => 'operation_failed_effect_unknown',
|
|
'result_json' => null,
|
|
'effect_may_have_applied' => 1,
|
|
'safe_to_resubmit' => 0,
|
|
'effect_resolution' => 'unknown',
|
|
'terminal_at' => $now - 5,
|
|
'read_at' => null,
|
|
'sealed_payload' => '',
|
|
'order_id' => null,
|
|
'created_at' => $now - 30,
|
|
'updated_at' => $now,
|
|
], $overrides), true);
|
|
return $model;
|
|
};
|
|
|
|
foreach (['applied', 'not_applied'] as $resolution) {
|
|
$display = CloudJobService::display($job([
|
|
'effect_resolution' => $resolution,
|
|
]));
|
|
$assert(($display['effect_resolution'] ?? null) === $resolution,
|
|
'Resolved terminal failure did not expose its bounded effect resolution.');
|
|
$assert(($display['status'] ?? null) === 'failed'
|
|
&& ($display['completed'] ?? null) === true
|
|
&& ($display['effect_may_have_applied'] ?? null) === true
|
|
&& ($display['safe_to_resubmit'] ?? null) === false,
|
|
'Effect convergence rewrote the original public failure contract.');
|
|
}
|
|
|
|
foreach ([
|
|
['effect_resolution' => 'unknown'],
|
|
['effect_resolution' => 'not_applicable'],
|
|
['effect_resolution' => 'internal_reviewed'],
|
|
['effect_resolution' => 'applied', 'effect_may_have_applied' => 0],
|
|
['effect_resolution' => 'applied', 'outcome' => 'succeeded',
|
|
'status' => 'succeeded'],
|
|
] as $overrides) {
|
|
$display = CloudJobService::display($job($overrides));
|
|
$assert(!array_key_exists('effect_resolution', $display),
|
|
'Public task DTO exposed a non-applicable or untrusted effect resolution.');
|
|
}
|
|
|
|
echo "Cloud resolved task presentation checks passed.\n";
|