74 lines
4.4 KiB
PHP
74 lines
4.4 KiB
PHP
<?php
|
|
ini_set('zend.exception_ignore_args', '1');
|
|
putenv('STABILITY_QA_MODE=consumers');
|
|
$noticeRoot = dirname(__DIR__, 2);
|
|
$noticeQA = $noticeRoot.'/storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742';
|
|
$noticeReceipt = __DIR__.'/case32-resource-notices-readonly-20261013.json';
|
|
if (is_file($noticeReceipt)) { throw new RuntimeException('Diagnóstico já registado.'); }
|
|
$app = require $noticeQA.'/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 {
|
|
$actor = App\Models\User::findOrFail(21);
|
|
$record = App\Models\Opportunity::findOrFail(32);
|
|
if ($record->opportunity_category !== 'land_rights') { throw new RuntimeException('Categoria divergente.'); }
|
|
request()->setUserResolver(fn () => $actor);
|
|
$access = app(App\Services\PortalProfileAccess::class);
|
|
if (! $access->canView($actor, $record)) { throw new RuntimeException('Leitura não autorizada para QA21.'); }
|
|
$service = app(App\Services\OpportunityResources::class);
|
|
$resources = [];
|
|
foreach (App\Services\OpportunityResources::KINDS as $kind) {
|
|
$resources[$kind] = $service->listing(32, $kind);
|
|
}
|
|
$method = new ReflectionMethod(App\Http\Controllers\OpportunityResourceController::class, 'assessment');
|
|
$notices = $method->invoke(app(App\Http\Controllers\OpportunityResourceController::class), $resources);
|
|
$contract = app(App\Services\OpportunityCanonicalContract::class);
|
|
$errors = [];
|
|
$binaryStatus = null;
|
|
try {
|
|
$contract->validateSubmission($record);
|
|
} catch (Illuminate\Validation\ValidationException $error) {
|
|
$errors = $error->errors();
|
|
} catch (Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $error) {
|
|
$binaryStatus = $error->getStatusCode();
|
|
}
|
|
$canonical = app(App\Services\OpportunityManagement::class)->values($record)['canonical'] ?? [];
|
|
$delivery = $contract->deliveryBlockers($canonical);
|
|
$receipt = [
|
|
'at'=>gmdate('c'), 'base_review'=>'396c691930bc', 'target'=>$target,
|
|
'SQL_read_only'=>true, 'QA_database_changes'=>0, 'active_changes'=>0,
|
|
'opportunity_id'=>32, 'QA_account'=>21,
|
|
'working_state'=>$access->state($record),
|
|
'assessment_notices'=>$notices,
|
|
'actual_submission_validation_errors'=>$errors,
|
|
'binary_validation_HTTP_status'=>$binaryStatus,
|
|
'delivery_blockers'=>$delivery,
|
|
'allowed_workflow_actions'=>$binaryStatus === null ? app(App\Services\OpportunityProfileWorkflow::class)->actions($actor, $record) : [],
|
|
'submission_validation_passed'=>$errors === [] && $binaryStatus === null && $delivery === [],
|
|
'issuer_edition_source_reference_assessment_not_required_by_submission'=>true,
|
|
'basis'=>[
|
|
'OpportunityResourceController::assessment produces notices only; save/transition do not consume this list.',
|
|
'OpportunityProfileWorkflow validates the canonical contract and delivery blockers for submission.',
|
|
'Resource metadata notices do not establish failed scan, invalid original, or rejected official source.',
|
|
],
|
|
'limits'=>[
|
|
'Read-only diagnostic of current state and existing services; not an HTTP submission or visual acceptance.',
|
|
'User-pasted text demonstrates presentation of assessment only; not document opening or workflow completion.',
|
|
'Synthetic QA attachments must not be represented as official documents or external decisions.',
|
|
],
|
|
];
|
|
file_put_contents($noticeReceipt, json_encode($receipt, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR).PHP_EOL);
|
|
echo json_encode(['record'=>32, 'working_state'=>$receipt['working_state'],
|
|
'submission_validation_passed'=>$receipt['submission_validation_passed'],
|
|
'submission_error_fields'=>array_keys($errors), 'delivery_blocker_fields'=>array_keys($delivery),
|
|
'binary_validation_HTTP_status'=>$binaryStatus, 'allowed_actions'=>$receipt['allowed_workflow_actions'],
|
|
'assessment_count'=>count($notices), 'active_changes'=>0, 'QA_database_changes'=>0], JSON_THROW_ON_ERROR).PHP_EOL;
|
|
} finally {
|
|
$db->rollBack();
|
|
}
|