6 lines
2.6 KiB
PHP
6 lines
2.6 KiB
PHP
<?php
|
|
use Illuminate\Support\Facades\DB;
|
|
$s=json_decode(file_get_contents(getenv('RECEIPT_COMPOSITION_STATE')),true);$out=$s['root'].'/supplier-documents-demo.json';if(!($s['supplierDocuments']??false)||is_file($out))throw new LogicException('New document demonstration required');require $s['app'].'/vendor/autoload.php';$app=require $s['app'].'/bootstrap/app.php';$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();$n=json_decode(file_get_contents($s['root'].'/native-fixture.json'),true);config(['database.connections.document_demo'=>$s['nativeConnection']]);$db=DB::connection('document_demo');$checks=[];$ok=function($v,$name)use(&$checks){if(!$v)throw new RuntimeException($name);$checks[]=$name;};$fingerprint=fn()=>hash('sha256',json_encode([$db->table('suppliers')->orderBy('id')->get(),$db->table('supplier_documents')->get(),$db->table('audit_logs')->orderBy('id')->get()]));$before=$fingerprint();$ok($db->table('supplier_documents')->count()===0&&$db->table('requisitions')->where('tenant_id',$n['tenant'])->count()===0,'live demo starts without attachments or main requests');$client=new GuzzleHttp\Client(['base_uri'=>'http://127.0.0.1:8076','http_errors'=>false,'timeout'=>25]);
|
|
foreach(['actor','issuer','validator']as$role){$jar=new GuzzleHttp\Cookie\CookieJar;$r=$client->get('/qa/enter/'.$role,['cookies'=>$jar]);$v=json_decode((string)$r->getBody(),true);$o=['cookies'=>$jar,'headers'=>['Accept'=>'application/json','X-SGF-Context'=>$v['context']]];$r=$client->get('/api/purchasing-suppliers/'.$n['supplier_ids'][0].'/documents',$o);$d=json_decode((string)$r->getBody(),true);$ok($role==='validator'?$r->getStatusCode()===403:($r->getStatusCode()===200&&$d['data']===[]),'private document list respects '.$role);if($role==='actor'){$r=$client->get('/api/purchasing-suppliers/'.$n['supplier_ids'][0],$o);$d=json_decode((string)$r->getBody(),true);$ok($r->getStatusCode()===200&&$d['documents_enabled']===true,'supplier screen capability exposes document module only in new composition');}}
|
|
foreach(['supplier-workspace.mjs','supplier-documents.mjs']as$file){$r=$client->get('/'.$file);$ok($r->getStatusCode()===200&&hash('sha256',(string)$r->getBody())===hash_file('sha256',$s['app'].'/public/'.$file),'served document source matches '.$file);}$ok($fingerprint()===$before,'live metadata checks preserve supplier versions attachments and audit');file_put_contents($out,json_encode(['passed'=>true,'checks'=>$checks,'before'=>$before,'after'=>$fingerprint(),'visual_review'=>false],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo count($checks)." supplier document demonstration checks passed.\n";
|