<?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.'/card-spec-private.json')||is_file($runtime.'/raw-CARD_SOURCE-private.json')){throw new RuntimeException('Supplemental card first-request guard');}
define('APP_PATH',getenv('SM7_ROOT').'/application/');
require APP_PATH.'common/enum/EnumBasics.php';require APP_PATH.'common/enum/order/OrderSource.php';require APP_PATH.'base/Security.php';
$actor=smLoad('actor-private.json');$boundary=smLoad('boundary-private.json');$case=null;
foreach(catCases(smLoad('candidates-private.json')['candidates']) as $candidate){if($candidate['name']==='CARD_SOURCE'){$case=$candidate;}}
if(!$case){throw new RuntimeException('No positively mapped card candidate');}
$proof=catSnapshot($db,$case,$boundary);$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'=>'catalog-card-supplement','name'=>'CARD_SOURCE','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_CAT_CARD_SOURCE']],
 'body'=>['mode'=>'urlencoded','urlencoded'=>[['key'=>'card_id','value'=>(string)$case['params']['card_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 original-table complete JSON contract',()=>pm.expect(pm.response.json()).to.deep.equal(expected));"]]]]];
smSave('card-spec-private.json',$case+['before'=>$proof]);smSave('card-collection-private.json',['apifoxCli'=>'2.2.8','info'=>['name'=>'Frozen supplemental card read'],'item'=>[$item]]);
echo json_encode(['lane'=>getenv('SM7_LANE'),'prepared_cases'=>1,'new_fixture_dml'=>0,'ddl'=>0]),PHP_EOL;
