Files
SGF/tests/Support/WorkshopFixture.php
T
nala 21a91f2aff Accept isolated WORKSHOP-RESOURCE-RECORD-v1 delivery
Record explicit workshop acceptance and preserve subsequent synthetic work without accepting receivables. Keep 080000/070000 unapplied, real workshop grants pending and operational issuance blocks intact. Exclude local credentials and real-data preservation reports.
2026-10-27 11:28:34 +02:00

28 lines
1.8 KiB
PHP

<?php
namespace Tests\Support;
use App\Models\User;
use App\Modules\Services\ServiceWorkflow;
use App\Modules\Workshop\WorkshopWorkflow;
use App\Shared\Context\CompanyContext;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
final class WorkshopFixture
{
public static function create(?array $base=null): array
{
WorkshopWorkflow::guard(); $f=$base??DocumentPreviewFixture::create();
$tech=User::create(['name'=>'Técnico Sintético Oficina','email'=>'tecnico-oficina@example.test','password'=>$f['password']]);
$reviewer=User::create(['name'=>'Verificador Sintético Oficina','email'=>'verificador-oficina@example.test','password'=>$f['password']]);
foreach([$tech,$reviewer] as $u) {
DB::table('company_memberships')->insert(['user_id'=>$u->id,'tenant_id'=>$f['tenant'],'company_id'=>$f['company']]);
IdentityFixture::grant($u->id,$f['tenant'],$f['company'],'company.view'); IdentityFixture::grant($u->id,$f['tenant'],$f['company'],'unit.view',$f['unit']);
}
foreach(['view','record'] as $r) IdentityFixture::grant($tech->id,$f['tenant'],$f['company'],'workshop.'.$r,$f['unit']);
foreach(['view','verify'] as $r) IdentityFixture::grant($reviewer->id,$f['tenant'],$f['company'],'workshop.'.$r,$f['unit']);
foreach(['view','open','assign','authorize'] as $r) IdentityFixture::grant($f['manager']->id,$f['tenant'],$f['company'],'workshop.'.$r,$f['unit']);
app(CompanyContext::class)->selectFor($f['manager']->id,$f['tenant'],$f['company'],$f['unit']);
$client=app(ServiceWorkflow::class)->save('clients',null,$f['manager']->id,['name'=>'Cliente Sintético da Oficina'],(string)Str::uuid())['id'];
return $f+['technician'=>$tech,'reviewer'=>$reviewer,'client'=>$client];
}
}