58 lines
4.1 KiB
PHP
58 lines
4.1 KiB
PHP
<?php
|
|
ini_set('zend.exception_ignore_args', '1');
|
|
putenv('STABILITY_QA_MODE=consumers');
|
|
$submissionRoot = dirname(__DIR__, 2);
|
|
$submissionQA = $submissionRoot.'/storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742';
|
|
$submissionReceipt = __DIR__.'/case32-manual-submission-readonly-20261013.json';
|
|
if (is_file($submissionReceipt)) { throw new RuntimeException('Confirmação já registada.'); }
|
|
$previous = json_decode(file_get_contents(__DIR__.'/case32-resource-notices-readonly-20261013.json'), true, 512, JSON_THROW_ON_ERROR);
|
|
$app = require $submissionQA.'/tools/portal-stability-runtime.php';
|
|
$db = Illuminate\Support\Facades\DB::connection();
|
|
$target = (array) $db->selectOne('SELECT current_database() AS database, inet_server_port() AS port');
|
|
if ($target !== ['database'=>'stability_consumers_20261011_084534_test', 'port'=>55441]) {
|
|
throw new RuntimeException('QA isolada obrigatória.');
|
|
}
|
|
$db->beginTransaction();
|
|
$db->statement('SET TRANSACTION READ ONLY');
|
|
try {
|
|
$record = App\Models\Opportunity::findOrFail(32);
|
|
if ($record->opportunity_category !== 'land_rights') { throw new RuntimeException('Categoria divergente.'); }
|
|
$context = $record->workflow_context ?? [];
|
|
$events = array_values(array_filter($context['events'] ?? [], fn ($row) => ($row['action'] ?? '') === 'submit'));
|
|
$event = $events ? $events[count($events)-1] : [];
|
|
$afterPrior = ! empty($event['at']) && new DateTimeImmutable($event['at']) > new DateTimeImmutable($previous['at']);
|
|
$audit = Illuminate\Support\Facades\DB::table('audit_events')
|
|
->where('source_system', 'portal-profiles-v1')->where('action', 'workflow_submit')
|
|
->whereRaw("after_data->>'record_id' = ?", ['32'])->orderByDesc('created_at')->first(['id', 'actor_user_id', 'created_at', 'after_data']);
|
|
$data = $audit ? json_decode($audit->after_data, true, 512, JSON_THROW_ON_ERROR) : [];
|
|
$access = app(App\Services\PortalProfileAccess::class);
|
|
$state = $access->state($record);
|
|
$auditMatches = $audit && (int) $audit->actor_user_id === 21 && ($data['after']['status'] ?? null) === 'submitted'
|
|
&& (int) ($data['after']['version'] ?? 0) === (int) $record->management_version;
|
|
$confirmed = $state === 'submitted' && (int) ($event['actor_id'] ?? 0) === 21 && $afterPrior && $auditMatches;
|
|
$receipt = [
|
|
'at'=>gmdate('c'), 'base_review'=>'396c691930bc', 'target'=>$target,
|
|
'SQL_read_only'=>true, 'QA_database_changes'=>0, 'active_changes'=>0,
|
|
'user_statement'=>'enviado', 'statement_scope_from_preceding_context'=>'QA21 submeteu o caso 32',
|
|
'opportunity_id'=>32, 'category'=>$record->opportunity_category, 'working_state'=>$state,
|
|
'management_version'=>(int) $record->management_version,
|
|
'latest_submission_event'=>array_intersect_key($event, array_flip(['actor_id', 'action', 'at', 'from', 'to', 'review_cycle', 'content_revision'])),
|
|
'submission_event_newer_than_previous_readonly_observation'=>$afterPrior,
|
|
'audit_matches_submission_version'=>(bool) $auditMatches,
|
|
'audit_id'=>$audit->id ?? null,
|
|
'audit_actor_id'=>$audit ? (int) $audit->actor_user_id : null,
|
|
'manual_submission_persisted'=>$confirmed,
|
|
'QA24_allowed_actions'=>$access->canView(App\Models\User::findOrFail(24), $record)
|
|
? app(App\Services\OpportunityProfileWorkflow::class)->actions(App\Models\User::findOrFail(24), $record) : [],
|
|
'limits'=>['No HTTP transition executed by this diagnostic.',
|
|
'Manual statement plus stored event/audit confirm submission only, not document opening, area presentation, review, approval or publication.',
|
|
'C135 automatic browser trust failure is not resolved by this manual proof.'],
|
|
];
|
|
file_put_contents($submissionReceipt, json_encode($receipt, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR).PHP_EOL);
|
|
echo json_encode(['case'=>32, 'manual_submission_persisted'=>$confirmed, 'working_state'=>$state,
|
|
'QA24_allowed_actions'=>$receipt['QA24_allowed_actions'], 'audit_matches'=>(bool) $auditMatches,
|
|
'active_changes'=>0, 'QA_database_changes'=>0], JSON_THROW_ON_ERROR).PHP_EOL;
|
|
} finally {
|
|
$db->rollBack();
|
|
}
|