<?php
declare(strict_types=1);date_default_timezone_set('Asia/Shanghai');require __DIR__.'/oracle.php';require __DIR__.'/cases.php';$db=smPdo();catSha();catActor($db);$runtime=getenv('SM7_RUNTIME');if(is_file($runtime.'/dining-spec-private.json')||is_file($runtime.'/raw-DINING_TODAY-private.json')){throw new RuntimeException('Dining first-request guard');}
define('APP_PATH',getenv('SM7_ROOT').'/application/');require APP_PATH.'base/Security.php';$case=null;foreach(n7Cases(smLoad('candidates-private.json')['candidates']) as $one){if($one['kind']==='dining'){$case=$one;}}if(!$case){throw new RuntimeException('No bounded dining candidate');}$proof=n7Snapshot($db,$case);$actor=smLoad('actor-private.json');$token=\app\base\Security::encrypt(implode("\t",[(string)$actor['id'],$actor['uuid'],$actor['marker'],'0','','',$actor['marker']]));$expected=json_encode($proof['body'],JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR);
$item=['id'=>'catalog7-dining','name'=>'DINING_TODAY','type'=>'http','metaInfo'=>['type'=>'HTTP'],'request'=>['method'=>'POST','url'=>getenv('SM7_BASE').$case['path'],'header'=>[['key'=>'token','value'=>$token],['key'=>'Content-Type','value'=>'application/x-www-form-urlencoded'],['key'=>'X-Pilot-Scenario','value'=>'PILOT_CAT7_DINING_TODAY']],'body'=>['mode'=>'urlencoded','urlencoded'=>[['key'=>'restaurant_id','value'=>(string)$case['params']['restaurant_id'],'type'=>'text']]]],'event'=>[['listen'=>'test','script'=>['type'=>'text/javascript','exec'=>["pm.test('HTTP 200',()=>pm.response.to.have.status(200));",'const expected='.$expected.';',"pm.test('independent department/menu complete JSON contract',()=>pm.expect(pm.response.json()).to.deep.equal(expected));"]]]]];
smSave('dining-spec-private.json',$case+['before'=>$proof]);smSave('dining-collection-private.json',['apifoxCli'=>'2.2.8','info'=>['name'=>'Frozen actual-today dining read'],'item'=>[['name'=>'One bounded readonly counter request','item'=>[$item]]]]);echo json_encode(['lane'=>getenv('SM7_LANE'),'prepared_cases'=>1,'actual_consumed_menus'=>count($proof['source_sets']['actual_today_menus']),'leaf_departments'=>count($proof['source_sets']['leaf_departments']),'business_dml_ddl'=>0]),PHP_EOL;
