make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();$queries=0;$checks=[];DB::listen(function()use(&$queries){$queries++;});$c=new App\Modules\Purchasing\SupplierDocumentsController;$runtime=new App\Modules\Purchasing\ReceiptRuntime; $check=function($fn,$status,$name)use(&$checks){try{$fn();throw new RuntimeException('Unexpected acceptance');}catch(Symfony\Component\HttpKernel\Exception\HttpException $e){if($e->getStatusCode()!==$status)throw $e;}$checks[]=$name;};config(['receipt_qa.supplier_documents_enabled'=>false]);$check(fn()=>$c->index(1,new Illuminate\Http\Request,$runtime),404,'disabled document metadata refuses before SQL');$check(fn()=>$c->preview(1,new Illuminate\Http\Request,$runtime),404,'disabled upload refuses before validation storage and SQL');config(['receipt_qa.supplier_documents_enabled'=>true]);$app->instance('env','production');$check(fn()=>$c->index(1,new Illuminate\Http\Request,$runtime),403,'production refuses synthetic document adapter before SQL');if($queries!==0||App\Shared\Context\ModuleNavigation::owner('api/purchasing-suppliers/1/documents/1/download')!=='purchasing')throw new RuntimeException('Document guard scope');$checks[]='document route belongs to purchasing and guard probes issue zero SQL';file_put_contents($out,json_encode(['passed'=>true,'checks'=>$checks,'database_queries'=>0],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo count($checks)." document guard checks passed.\n";