<?php
declare(strict_types=1);$root=$argv[1]??'';require $root.'/vendor/autoload.php';require $root.'/vendor/topthink/framework/src/helper.php';require __DIR__.'/OrderReadResponseRelatedCandidate.php';require __DIR__.'/ControllerModelDoubles.php';
function getStoreId():int{return 2147001111;}
function app_name():string{return 'store';}
$common=file_get_contents($root.'/app/common.php');preg_match('/^function format_time\([^\n]+\n\{.*?^\}/ms',$common,$helper);eval($helper[0]);
require __DIR__.'/storeDeliveryControllerCandidate.php';require __DIR__.'/terminalDeliveryControllerCandidate.php';require __DIR__.'/storeRefundControllerCandidate.php';require __DIR__.'/terminalRefundControllerCandidate.php';
class RelatedBoundaryMysql extends \think\db\connector\Mysql {public function connect(array $config=[],$linkNum=0,$autoConnection=false):\PDO{throw new RuntimeException('No PDO');}public function getFields(string $table):array{return [];}}
class RelatedBoundaryDm extends \app\common\database\Dm {public function connect(array $config=[],$linkNum=0,$autoConnection=false):\PDO{throw new RuntimeException('No PDO');}public function getFields(string $table):array{return [];}}
$cfg=new \think\Config();$cfg->set(['success'=>200,'error'=>500],'status');\think\Container::getInstance()->instance(\think\Config::class,$cfg);\think\Container::getInstance()->instance('config',$cfg);\think\App::$trace_id='123456789abcd';$request=new \think\Request();\think\Container::getInstance()->instance(\think\Request::class,$request);\think\Container::getInstance()->instance(\think\Cookie::class,new \think\Cookie($request));$count=0;$check=static function($ok,$why)use(&$count){$count++;if(!$ok)throw new RuntimeException($why);};$wire=static function($response){if(!$response instanceof \think\response\Json)throw new RuntimeException('Actual Json required');return json_decode($response->getContent(),true);};
$make=static function($class)use($request){$c=(new ReflectionClass($class))->newInstanceWithoutConstructor();$p=new ReflectionProperty(\cores\BaseController::class,'request');$p->setAccessible(true);$p->setValue($c,$request);return $c;};
foreach([false,true] as $dm){$db=new \think\DbManager();$db->setConfig(['default'=>'test','auto_timestamp'=>false,'connections'=>['test'=>['type'=>'\\'.($dm?RelatedBoundaryDm::class:RelatedBoundaryMysql::class),'builder'=>\think\db\builder\Mysql::class,'prefix'=>'yoshop_','fields_strict'=>false]]]);\think\Container::getInstance()->instance(\think\DbManager::class,$db);
foreach(['store','terminal'] as $module){$delivery=$make('app\\'.$module.'\\controller\\order\\Delivery');$refund=$make('app\\'.$module.'\\controller\\order\\Refund');$GLOBALS['delivery_controller_detail']=null;$b=$wire($delivery->detail(1));$check($b===['status'=>200,'message'=>'success','data'=>['detail'=>null],'trace_id'=>'123456789abcd'],'Existing delivery null success contract');
$GLOBALS['delivery_controller_detail']=new \app\common\model\order\Delivery(['delivery_id'=>1,'eorder_html'=>'','delivery_method'=>10]);$b=$wire($delivery->detail(1));$check($b['data']['detail']['delivery_id']===1&&$b['data']['detail']['eorder_html']==='','Existing real Model delivery detail raw contract');
foreach([null,false,[]] as $absent){$GLOBALS['refund_controller_detail']=$absent;$b=$wire($refund->detail(1));$check($b===['status'=>500,'message'=>'未找到该售后单记录','data'=>[],'trace_id'=>'123456789abcd'],'Original refund absence error contract');}
foreach([['order_refund_id'=>2,'refund_money'=>$dm?0:'0.00','keep'=>[]],new \app\common\model\OrderRefund(['order_refund_id'=>2,'refund_money'=>$dm?0:'0.00','send_time'=>0])] as $detail){$GLOBALS['refund_controller_detail']=$detail;$b=$wire($refund->detail(2));$check($b['data']['detail']['refund_money']==='0.00'&&$b['data']['detail']['order_refund_id']===2,'Actual refund array or Model boundary');if(is_object($detail))$check($b['data']['detail']['send_time']==='','Actual getSendTimeAttr through Controller Json');}
$GLOBALS['delivery_controller_items']=[['delivery_id'=>1,'orderData'=>['pay_price'=>$dm?0:'0.00','user'=>['balance'=>$dm?0:'0.00']],'goods'=>[['delivery_num'=>0,'goods'=>['line_price'=>$dm?0:'0.00','goods_weight'=>0.5]]]]];$b=$wire($delivery->list());$row=$b['data']['list']['data'][0];$check($b['data']['list']['per_page']===10&&$b['data']['list']['total']===1,'Actual delivery Paginator shape');$check($row['orderData']['pay_price']==='0.00'&&$row['orderData']['user']['balance']==='0.00'&&$row['goods'][0]['goods']['line_price']==='0.00','Three explicit nested source paths');$check($row['goods'][0]['delivery_num']===0&&$row['goods'][0]['goods']['goods_weight']===0.5,'NonDEC fields untouched');
$GLOBALS['refund_controller_items']=[['order_refund_id'=>2,'refund_money'=>$dm?0:'0.00','orderData'=>['total_price'=>$dm?0:'0.00'],'orderGoods'=>['goods_price'=>$dm?0:'0.00'],'user'=>['balance'=>$dm?0:'0.00']]];$b=$wire($refund->list());$row=$b['data']['list']['data'][0];$check($b['data']['list']['per_page']===10&&$row['refund_money']==='0.00'&&$row['orderData']['total_price']==='0.00'&&$row['orderGoods']['goods_price']==='0.00'&&$row['user']['balance']==='0.00','Actual refund Paginator and explicit source paths');}
$check($db->getQueryTimes()===0,'Explicit noIO models and actual Controller Json');}
echo json_encode(['assertions'=>$count,'PDO_opens'=>0,'actual_Controller_Paginator_Json'=>true,'auth_bypass_only_in_unit_test'=>true]),"\n";
