9 lines
3.2 KiB
PHP
9 lines
3.2 KiB
PHP
<?php
|
|
$enter('actor',0,['module'=>'commercial']);$ctx=app(App\Shared\Context\CompanyContext::class);$ctx->selectFor($f['actor'],$f['tenant'],$f['company'],$f['unit']);auth()->setUser(App\Models\User::findOrFail($f['actor']));request()->attributes->set('sgf_module','commercial');$key=DB::table('geo_territories')->where('level',1)->orderBy('designation')->value('territory_key');$version=App\Shared\Geography\Catalogue::active()->source_version;$selection=App\Shared\Geography\Catalogue::selection($version,$key);$scope=['tenant_id'=>$f['tenant'],'company_id'=>$f['company'],'unit_key'=>0,'module_key'=>'commercial','kind'=>'client','provider'=>'sgf'];$ids=[];
|
|
// Prepared reader fixtures only; the41 command checks retain their own immutable proof.
|
|
for($i=0;$i<26;$i++){$id=app(App\Modules\Services\ServiceWorkflow::class)->save('clients',null,$f['actor'],['name'=>'Cliente QA paginação '.str_pad((string)$i,2,'0',STR_PAD_LEFT)],(string)Illuminate\Support\Str::uuid())['id'];$ids[]=$id;DB::table('geo_locations')->insert($scope+['entity_id'=>$id,'revision'=>1,'selection'=>json_encode($selection,JSON_THROW_ON_ERROR),'actor_id'=>$f['actor'],'reason'=>'Fixture sintética de leitura paginada.','updated_at'=>now()]);}
|
|
$filter='?province='.urlencode($selection['codes']['province']);$a=$call('actor',$base.'/segments/client'.$filter);$b=$call('actor',$base.'/segments/client'.$filter.'&after='.$a['data']['next_after']);$ok($a['status']===200&&count($a['data']['data'])===25&&$a['data']['next_after']!==null,'segmentation first page contains25 authorised locations');$ok($b['status']===200&&count($b['data']['data'])===2&&$b['data']['next_after']===null,'segmentation cursor reaches final two locations');$one=array_column($a['data']['data'],'entity_id');$two=array_column($b['data']['data'],'entity_id');$ok(count(array_unique([...$one,...$two]))===27&&array_intersect($one,$two)===[],'cursor pages contain no duplicate or omitted visible locations');
|
|
DB::table('geo_locations')->insert($scope+['entity_id'=>$f['pending_client'],'revision'=>1,'selection'=>json_encode($selection,JSON_THROW_ON_ERROR),'actor_id'=>$f['actor'],'reason'=>'Fixture negativa sem associação de módulo.','updated_at'=>now()]);$a=$call('actor',$base.'/segments/client'.$filter);$b=$call('actor',$base.'/segments/client'.$filter.'&after='.$a['data']['next_after']);$all=[...array_column($a['data']['data'],'entity_id'),...array_column($b['data']['data'],'entity_id')];$ok(count($all)===27&&!in_array($f['pending_client'],$all,true),'prepared metadata cannot bypass an absent client module association');
|
|
DB::table('geo_locations')->where($scope)->where('entity_id',$f['pending_client'])->delete();$r=$call('actor',$base.'/segments/client?after=-1');$ok($r['status']===422,'invalid segmentation cursor rejected');$ctx->clear();request()->attributes->remove('sgf_module');
|
|
file_put_contents($out,json_encode(['passed'=>true,'checks'=>$checks,'prepared_reader_fixtures'=>26,'actual_command_checks_reused'=>41,'pages'=>[25,2],'unassociated_client_hidden'=>true,'protected_pending_client_location_fixture_removed'=>true,'database_scope'=>'new QA fixture only','visual_review'=>false],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo count($checks)." pagination boundary checks passed.\n";
|