<?php
declare(strict_types=1);
require __DIR__.'/hardware_contract.php';require __DIR__.'/contract.php';require __DIR__.'/hardware_cases.php';$db=smPdo();$f=smLoad('h7-fixture-private.json');$pre=smLoad('h7-preflight-private.json');$actor=smLoad('actor-private.json');$s=$f['seed'];$ids=$f['ids'];$own=hcOwnRows($db,$s,$ids);$sha=n6Sha();if(smDigest($own)!==smDigest($f['own_rows'])||(int)$own['initial_menu']['meal_type']!==4){smSave('h7-native-not-run-private.json',['reason'=>'owned chain changed','database_dml_ddl'=>0]);exit(78);}$scope=hcConsumedSource($db,$s,$ids,$pre,$actor,4);
require getenv('SM7_ROOT').'/application/base/Security.php';$token=\app\base\Security::encrypt(implode("\t",[(string)$actor['id'],$actor['uuid'],$actor['marker'],'0','','',$actor['marker']]));$m=$own['initial_menu'];$img=$own['date_menu_hardware_img'];$staff=$own['staff'];$dish=['hardware_img_uuid'=>'','recommend_uuid'=>'','date_menu_uuid'=>$m['uuid'],'select_adjust'=>empty($m['select_adjust'])?'':(string)$m['select_adjust'],'dishes_uuid'=>$m['dishes_uuid'],'code'=>$m['code'],'name'=>$own['dishes']['name'],'weight'=>$m['weight'],'in_recipes'=>1,'un_edit'=>1];$hardware=['code'=>0,'message'=>true,'data'=>[['id'=>$img['id'],'uuid'=>$img['uuid'],'menu_date'=>$img['menu_date'],'meal_times'=>$img['meal_times'],'img'=>$img['img'],'dishes'=>[$dish,[]]]]];$check=['code'=>0,'message'=>'查询成功','data'=>['rows'=>[['staff_uuid'=>$staff['uuid'],'head_img'=>'','staff_name'=>$staff['name'],'sex'=>$staff['sex'],'meal_times'=>$m['meal_times'],'is_flag'=>true]],'total'=>1]];
$items=[];$spec=[];foreach(n6HardwareCases($f) as $i=>$case){$expected=$i===0?$hardware:$check;$body=[];foreach($case['params'] as $k=>$v){$body[]=['key'=>$k,'value'=>(string)$v,'type'=>'text'];}$items[]=['id'=>'own-h7-'.$i,'name'=>$case['name'],'type'=>'http','metaInfo'=>['type'=>'HTTP'],'request'=>['method'=>'POST','header'=>[['key'=>'token','value'=>$token],['key'=>'Content-Type','value'=>'application/x-www-form-urlencoded'],['key'=>'X-Pilot-Scenario','value'=>'PILOT_N6_'.$case['name']]],'url'=>getenv('SM7_BASE').$case['path'],'body'=>['mode'=>'urlencoded','urlencoded'=>$body]],'event'=>[['listen'=>'test','script'=>['type'=>'text/javascript','exec'=>["pm.test('HTTP 200',()=>pm.response.to.have.status(200));",'const expected='.json_encode($expected,JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR).';',"pm.test('independent owned source complete JSON contract',()=>pm.expect(pm.response.json()).to.deep.equal(expected));"]]]]];$spec[]=$case+['expected'=>$expected];}
smSave('h7-native-before-private.json',['source_sha256'=>$sha,'own_rows'=>$own,'consumed_source'=>$scope,'ids'=>$ids,'database_dml_ddl'=>0]);smSave('h7-native-spec-private.json',$spec);smSave('h7-native-collection-private.json',['apifoxCli'=>'2.2.8','info'=>['name'=>'Frozen native H7 readonly '.getenv('SM7_LANE')],'item'=>[['name'=>'Existing own relation reads only','item'=>$items]]]);echo json_encode(['lane'=>getenv('SM7_LANE'),'native_cases'=>3,'own_rows_verified'=>7,'database_dml_ddl'=>0]),PHP_EOL;
