orderBy('id')->get()->toJson();$pair=DB::table('portal_superuser_pair')->orderBy('id')->get()->toJson(); if(!DB::table('portal_superuser_pair')->where(fn($q)=>$q->where('first_user_id',2)->orWhere('second_user_id',2))->exists()||!DB::table('portal_role_assignments')->where('user_id',2)->where('role','promoter')->whereNull('revoked_at')->exists())throw new RuntimeException('Existing restored dual-role actor required; no role grant is created'); $actors=[];foreach([2=>'dual_promoter',13=>'super_only']as$id=>$name){$password=bin2hex(random_bytes(20));$alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';$secret='';for($i=0;$i<32;$i++)$secret.=$alphabet[random_int(0,31)];$email='qa-promoter-context-'.$id.'@example.invalid';DB::table('users')->where('id',$id)->update(['name'=>'QA contexto '.$name,'email'=>$email,'password'=>Hash::make($password),'two_factor_secret'=>Crypt::encrypt($secret),'two_factor_recovery_codes'=>Crypt::encrypt('[]'),'two_factor_confirmed_at'=>now(),'email_verified_at'=>now(),'remember_token'=>null]);$actors[$name]=compact('id','email','password','secret');} $operator=DB::table('portal_role_assignments')->where('user_id',2)->where('role','promoter')->where('source','internal-portal-designation')->whereNull('revoked_at')->value('organization_id'); $original=Opportunity::whereNull('owner_user_id')->firstOrFail();$record=$original->replicate();$record->reference='QA-CONTEXT-PROMOTER-20261015';$record->slug='qa-context-promoter-20261015';$record->title='QA sintética — abertura de editor por Promotor e Superutilizador';$record->owner_user_id=2;$record->organization_id=$operator;$record->opportunity_category='investment_project';$record->status='draft';$record->published_at=null;$record->workflow_context=['state'=>'draft','operator_organization_id'=>$operator,'contributors'=>[]];$record->management_version=1;$record->save(); $foreign=$record->replicate();$foreign->reference='QA-CONTEXT-FOREIGN-20261015';$foreign->slug='qa-context-foreign-20261015';$foreign->owner_user_id=14;$foreign->save(); if($roles!==DB::table('portal_role_assignments')->orderBy('id')->get()->toJson()||$pair!==DB::table('portal_superuser_pair')->orderBy('id')->get()->toJson())throw new RuntimeException('Role data changed'); $f=['url'=>'http://127.0.0.1:18520','database'=>$target['database'],'actors'=>$actors,'record_id'=>$record->id,'foreign_record_id'=>$foreign->id,'organization_id'=>$operator,'role_assignments_sha256'=>hash('sha256',$roles),'superuser_pair_sha256'=>hash('sha256',$pair)]; file_put_contents('C:/Users/macbook/.config/investmoz/promotor-contexto-QA-20261015/fixture-private.json',json_encode($f,JSON_THROW_ON_ERROR)); file_put_contents(__DIR__.'/FIXTURE-QA.json',json_encode(['target'=>portalQaAssertTarget($target),'dual_role_account_id'=>2,'super_only_account_id'=>13,'synthetic_record_id'=>$record->id,'foreign_synthetic_record_id'=>$foreign->id,'no_roles_or_pair_changed'=>true,'active_changes'=>0,'credentials'=>'synthetic QA only, private and not attached'],JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));echo json_encode(['QA_fixture_ready'=>true,'no_roles_granted'=>true,'record_id'=>$record->id]);