Files
SGF/scripts/workshop-fixture.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

25 lines
2.7 KiB
PHP

<?php
require __DIR__.'/../vendor/autoload.php';
$app=require __DIR__.'/../bootstrap/app.php'; $app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
\App\Modules\Workshop\WorkshopWorkflow::guard();
$file='C:/laragon/data/sgf-tempo/secrets/browser-fixture.json';
$f=json_decode(file_get_contents($file),true,32,JSON_THROW_ON_ERROR);
if(\Illuminate\Support\Facades\DB::table('wo_orders')->exists()) throw new RuntimeException('Workshop proof must be empty; nothing deleted.');
$day=now('Africa/Johannesburg')->subDay()->format('Y-m-d');
\Carbon\Carbon::setTestNow(\Carbon\Carbon::parse($day.' 08:00:00','Africa/Johannesburg'));
try {
$fx=\Tests\Support\WorkshopFixture::create($f+['manager'=>\App\Models\User::findOrFail($f['manager_id']),'reader'=>\App\Models\User::findOrFail($f['reader_id'])]);
$w=app(\App\Modules\Workshop\WorkshopWorkflow::class); $ctx=app(\App\Shared\Context\CompanyContext::class);
$select=fn($actor)=>$ctx->selectFor($actor,$f['tenant'],$f['company'],$f['unit']); $key=fn()=>(string)\Illuminate\Support\Str::uuid();
$select($f['manager_id']);
$order=$w->open($f['manager_id'],['reference'=>'OT-TEST-PRINCIPAL','client_id'=>$fx['client'],'equipment_identifier'=>'EQ-TEST-PC','equipment_description'=>'Computador sintético para prova','serial'=>'SER-TEST-PC','request'=>'Diagnóstico e reparação sintéticos.','location'=>'Local sintético','evidence'=>'Pedido artificial, sem operação real.'],$key())['id'];
$w->record($order,$f['manager_id'],['kind'=>'assignment','origin'=>'TEST-ASSIGN','version'=>1,'revision'=>0,'technician_id'=>$fx['technician']->id],$key());
$select($fx['technician']->id);
$task=$w->record($order,$fx['technician']->id,['kind'=>'task','origin'=>'TEST-TASK','version'=>1,'revision'=>1,'description'=>'Intervenção sintética principal.'],$key())['id'];
$select($f['manager_id']);
$auth=$w->record($order,$f['manager_id'],['kind'=>'authorization','origin'=>'TEST-AUTH','version'=>1,'revision'=>2,'task_id'=>$task,'authorized_by'=>'Representante sintético do cliente','capacity'=>'Responsável do cliente apenas no ensaio','authorized_at'=>$day.'T07:59:00+02:00','channel'=>'Documento artificial','scope'=>'Somente a tarefa principal de diagnóstico/reparação.','evidence'=>'TEST-COMPROVATIVO-1'],$key())['id'];
$out=['client'=>$fx['client'],'technician_id'=>$fx['technician']->id,'reviewer_id'=>$fx['reviewer']->id,'order'=>$order,'task'=>$task,'auth'=>$auth,'day'=>$day];
file_put_contents($file,json_encode($f+['workshop'=>$out],JSON_THROW_ON_ERROR));
} finally { \Carbon\Carbon::setTestNow(); }
echo "Workshop fixture prepared only in sgf_tempo_test: three synthetic roles and a historical test clock for authorization. No time/material records pre-created.\n";