getRawOriginal(); $service=app(OpportunityManagement::class);$payload=$service->values($r)['canonical']; $proof=['target'=>portalQaAssertTarget($target),'application_booted'=>true,'uses_new_classification_service'=>class_exists('App\\Services\\OpportunityClassification'),'checks'=>[]]; $check=function($k,$v)use(&$proof){if(!$v)throw new RuntimeException($k);$proof['checks'][$k]=true;}; $check('restored_previous_sources_do_not_load_new_service',$proof['uses_new_classification_service']===false); $check('new_JSON_and_history_recovered_without_migration',count($payload['relations'])===9 && count($r->workflow_context['classification_decisions'])>0 && isset($payload['enterprise_size'])); $check('rollback_contract_accepts_preserved_payload',app(OpportunityCanonicalContract::class)->draft($payload)===$payload); DB::beginTransaction(); try { $saved=$service->save(User::findOrFail($f['actors']['promoter']['id']),['etag'=>$service->etag($r),'canonical'=>$payload,'reason'=>'Prova transacional de compatibilidade da reversão sem apagar dados usados.'],$r->id); $check('previous_editor_can_save_preserved_JSON',$service->values($saved)['canonical']===$payload); $check('publication_decisions_and_retired_history_preserved',$saved->workflow_context['publication']===$r->workflow_context['publication'] && $saved->workflow_context['classification_decisions']===$r->workflow_context['classification_decisions'] && count($saved->workflow_context['canonical_items']['deleted'])===count($r->workflow_context['canonical_items']['deleted'])); } finally {DB::rollBack();} $check('QA_record_unchanged_after_reversal_proof',$r->fresh()->getRawOriginal()===$before); $proof['result']='passed';$proof['active_changes']=0;$proof['no_down_or_delete_executed']=true;$proof['http_or_visual_reversal_test']=false; file_put_contents(__DIR__.'/REVERSAO-COMPAT-QA.json',json_encode($proof,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));echo json_encode(['result'=>'passed','checks'=>count($proof['checks']),'active_changes'=>0]);