20 lines
2.7 KiB
PHP
20 lines
2.7 KiB
PHP
<?php
|
|
require __DIR__.'/boot-QA.php';
|
|
use Illuminate\Support\Facades\DB;
|
|
$service=app(App\Services\InvestmentZoneOperationalDetails::class);$z=App\Models\InvestmentZone::findOrFail('0ae14c9a-1adb-4ee7-8094-d5d54d4e75f1');$checks=[];
|
|
$checks['private_325_25_recovered_after_candidate_restoration']=(float)app(App\Services\InvestmentZoneOperationalProfile::class)->management($z)['operational_details']['conditions'][0]['value']===325.25;
|
|
$checks['public_225_75_still_version20']=(float)$service->publicData($z)['conditions'][0]['value']===225.75 && (int)$z->version_no===20;
|
|
$hash=app(App\Services\InvestmentZoneOperationalDetailsInstallation::class)->fingerprint();
|
|
$checks['only_140000_added']=DB::table('migrations')->where('migration',App\Services\InvestmentZoneOperationalDetails::MIGRATION)->count()===1;
|
|
$migration=require $source.'/database/migrations/'.App\Services\InvestmentZoneOperationalDetails::MIGRATION.'.php';
|
|
try{$migration->up();$checks['unauthenticated_migration_refused']=false;}catch(RuntimeException $e){$checks['unauthenticated_migration_refused']=str_contains($e->getMessage(),'autenticada');}
|
|
try{$migration->down();$checks['destructive_down_after_use_refused']=false;}catch(RuntimeException $e){$checks['destructive_down_after_use_refused']=str_contains($e->getMessage(),'compatível');}
|
|
$before=json_decode(file_get_contents(__DIR__.'/BASELINE-QA.json'),true)['tables'];$changed=[];$preserved=0;
|
|
foreach($before as$name=>$old){$current=DB::selectOne('SELECT md5(COALESCE(string_agg(md5(row_to_json(t)::text),\'\' ORDER BY row_to_json(t)::text),\'\')) AS hash FROM "'.str_replace('"','""',$name).'" t')->hash;if($old===$current){$preserved++;}else{$changed[]=$name;}}
|
|
$allowed=['investment_zones','investment_zone_revisions','organizations','migrations','audit_events','users','login_events'];$unexpected=array_values(array_diff($changed,$allowed));$checks['other_QA_tables_preserved']=$unexpected===[];
|
|
$fixture=json_decode(file_get_contents(__DIR__.'/FIXTURE-L1.json'),true);$checks['no_organization_duplicated']=DB::table('organizations')->count()===$fixture['organization_count'];
|
|
$checks['old_editor_asset_observed']=str_contains(file_get_contents(__DIR__.'/ASSETS-ANTERIOR-OBSERVADOS.json'),'zone-8hN0xbD8.js');
|
|
foreach($checks as$k=>$v){if(!$v){throw new RuntimeException($k.': '.json_encode($changed));}}
|
|
$result=['candidate'=>'parques-L1-QA-'.substr($hash,0,12),'code_hash'=>$hash,'target'=>$target,'checks'=>$checks,'QA_tables_unchanged'=>$preserved,'QA_tables_changed'=>$changed,'unexpected_QA_tables_changed'=>$unexpected,'sources'=>12,'build_files'=>162,'retained_functional_sources'=>8,'active_authorized'=>false];
|
|
file_put_contents(__DIR__.'/FINAL-QA.json',json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));echo json_encode($result,JSON_UNESCAPED_UNICODE);
|