Files
Investidor-V2/tools/portal-next-target-state-qa.php
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

41 lines
2.5 KiB
PHP

<?php
use App\Models\Opportunity;
use App\Services\OpportunityCanonicalContract;
use App\Services\OpportunityManagement;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\ValidationException;
$root = dirname(__DIR__);
require $root.'/vendor/autoload.php';
require __DIR__.'/portal-qa-environment.php';
$target = portalQaEnvironment();
$app = require $root.'/bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
$identity = portalQaAssertTarget($target);
// Match the existing guarded HTTP QA entry point, not the inactive defaults.
config(['portal.opportunity_modular_profiles_qa_enabled' => true, 'portal.opportunity_other_qa_subtypes.qa-test-subtype' => ['approved' => true, 'version' => 'synthetic-acceptance-v1', 'decision_reference' => 'Synthetic QA acceptance fixture only; real subtypes require functional approval', 'gates' => ['technical_review', 'legal_territorial_review']]]);
$proof = DB::transaction(function () use ($identity) {
DB::statement('SET TRANSACTION READ ONLY');
$rows = [];
foreach (range(42, 49) as $id) {
$o = Opportunity::find($id);
if (! $o) {
continue;
}try {
app(OpportunityCanonicalContract::class)->validateSubmission($o);
$errors = [];
} catch (ValidationException$e) {
$errors = $e->errors();
}$p = app(OpportunityManagement::class)->values($o)['canonical'];
$rows[] = ['id' => $id, 'category' => $o->opportunity_category, 'mode' => $p['module_details']['mode'] ?? $p['business_transaction']['history_status'] ?? null, 'profile_version' => $p['module_profile_version'] ?? null, 'status' => $o->status, 'errors' => $errors];
}
return ['at' => gmdate('c'), 'target' => $identity, 'read_only' => true, 'active_writes' => 0, 'current_modular_records' => $rows,
'responsibilities' => DB::table('portal_role_assignments')->where('user_id', '>=', 20)->whereNull('revoked_at')->where('starts_at', '<=', now())->where(fn ($q) => $q->whereNull('expires_at')->orWhere('expires_at', '>', now()))->get(['user_id', 'role', 'responsibilities']),
'holders' => DB::table('portal_superuser_pair')->where('id', 1)->first(['first_user_id', 'second_user_id', 'version'])];
});
file_put_contents($root.'/storage/app/private/investmoz-v2/portal-audit/next-target-state-qa.json', json_encode($proof, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR));
echo json_encode($proof, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR).PHP_EOL;