11 lines
2.5 KiB
PHP
11 lines
2.5 KiB
PHP
<?php
|
|
use Illuminate\Support\Facades\{DB,Crypt};
|
|
$s=json_decode(file_get_contents(getenv('RECEIPT_COMPOSITION_STATE')),true);$out=$s['root'].'/stock-period-guards.json';if(!($s['stockPeriod']??false)||!is_file($s['root'].'/stock-period-result.json')||is_file($out))throw new LogicException('Completed period fixture required');
|
|
require $s['app'].'/vendor/autoload.php';$app=require $s['app'].'/bootstrap/app.php';$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();App\Modules\Purchasing\BudgetAdapter::guard();class_exists(App\Modules\Inventory\CompositionStockRead::class);
|
|
$profile=json_decode(file_get_contents($s['root'].'/stock-binding.json'),true);config(['database.connections.period_guard'=>$profile['connection']]);$source=DB::connection('period_guard');$binding=array_values($profile['bindings'])[0];$filters=['from'=>'2026-11-01','to'=>'2026-11-03','search'=>'','warehouse_id'=>null,'page'=>1,'per_page'=>25];$fingerprint=hash('sha256','isolated-expiry-observation');$report=new App\Modules\Inventory\StockPeriodReport($source);$result=$report->read($binding,$fingerprint,$filters,null);$cut=json_decode(Crypt::decryptString($result['snapshot']),true);$checks=[];
|
|
foreach([-601,60]as$delta){$v=$cut;$v['observed']=time()+$delta;$status=0;try{$report->read($binding,$fingerprint,$filters,Crypt::encryptString(json_encode($v)));}catch(Symfony\Component\HttpKernel\Exception\HttpException $e){$status=$e->getStatusCode();}if($status!==409)throw new RuntimeException('Invalid report observation time');$checks[]=$delta<0?'expired report reference requires refresh':'future-dated report reference is refused';}
|
|
$flag=config('receipt_qa.stock_period_enabled');config(['receipt_qa.stock_period_enabled'=>false]);$status=0;
|
|
try{(new App\Modules\Inventory\CompositionStockRead)->index(Illuminate\Http\Request::create('/api/stock-read?view=period&from=2026-11-01&to=2026-11-03'),app(App\Shared\Context\CompanyContext::class),app(App\Modules\Identity\Services\Permissions::class));}catch(Symfony\Component\HttpKernel\Exception\HttpException $e){$status=$e->getStatusCode();}finally{config(['receipt_qa.stock_period_enabled'=>$flag]);}
|
|
if($status!==404)throw new RuntimeException('Disabled report must not access its source');$checks[]='disabled report refuses before selecting a context or source';
|
|
file_put_contents($out,json_encode(['passed'=>true,'checks'=>$checks,'scope'=>'direct report/adapter probes, not middleware','business_commands'=>0,'visual_review'=>false],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo "3 period guard checks passed.\n";
|