<?php
declare(strict_types=1);
require __DIR__.'/../vendor/autoload.php';
require __DIR__.'/../vendor/topthink/framework/src/helper.php';
class RowFixture { private array $data; function __construct(array $data){$this->data=$data;} function toArray(){return $this->data;} }
class UpgradeUser { static function getCurrentLoginUser($x){return new RowFixture(['user_id'=>7,'mobile'=>'19900000001']);} static function getCurrentLoginUserId($x){return 7;} }
class UpgradeStaff { static $data=[]; static function getOne($x){return new RowFixture(self::$data);} }
class UpgradeScale { function latest($id){return ['summary'=>['weight'=>['value'=>90],'bmi'=>['value'=>24]]];} }
class UpgradeWeightModel { function where($x){return $this;} function field($x){return $this;} function order(...$x){return $this;} function find(){return ['bmi'=>23];} }
class UpgradeWeightService { static $data=['latest_weight'=>85,'goal_weight'=>60]; function status(){return self::$data;} }
class UpgradeDisease { static function getAllData($x){return [];} }
class UpgradeHabit { function detail($id){return [];} }
class UpgradeOther { function getOtherInfo($id){return [];} }
class UpgradeMeal { function index($date){return [];} }
class UpgradeMotion { static function getUserMovementDay($date){return [];} }
foreach([
 'UpgradeUser'=>'app\\api\\service\\User', 'UpgradeStaff'=>'app\\api\\model\\staff\\Staff',
 'UpgradeScale'=>'app\\api\\service\\WellandScale', 'UpgradeWeightModel'=>'app\\api\\model\\user\\UserWeight',
 'UpgradeWeightService'=>'app\\api\\service\\user\\UserWeight', 'UpgradeDisease'=>'app\\api\\model\\user\\Disease',
 'UpgradeHabit'=>'app\\store\\service\\staff\\Habit','UpgradeOther'=>'app\\api\\service\\user\\OtherInfo',
 'UpgradeMeal'=>'app\\api\\service\\meal\\Meal','UpgradeMotion'=>'app\\api\\service\\user\\UserMotion'
] as $from=>$to) class_alias($from,$to);
$enterprise='10052';
function getEnterpriseNO(){return $GLOBALS['enterprise'];}
function getStoreId(){return 10001;}
function get_bmi_cn($value){return 'fixture-bmi';}
$app=new \think\App();
\think\facade\Config::set(['success'=>200,'error'=>500],'status');
\think\App::$trace_id='upgrade-fixture';
require __DIR__.'/upgrade-baseline/Passport.php';
require __DIR__.'/upgrade-baseline/Archive.php';
$checks=0;
function verifyUpgrade($condition,$message){$GLOBALS['checks']++;if(!$condition)throw new RuntimeException($message);}
function bare($class){return (new ReflectionClass($class))->newInstanceWithoutConstructor();}
foreach(['10052','10053','10001','10042','10056'] as $enterprise){
 $old=bare('app\\api\\controller\\PassportUpgradeBaseline')->enterpriseAuth()->getData();
 $new=bare('app\\api\\controller\\Passport')->enterpriseAuth()->getData();
 if($enterprise==='10053'){
   verifyUpgrade($old['data']['auth']['face_photo']===false && $new['data']['auth']['face_photo']===true,'10053 enables face photo');
   $old['data']['auth']['face_photo']=true;
 }
 verifyUpgrade($old===$new,$enterprise.' other enterprise auth response unchanged');
}
foreach([['weight'=>'67.5'],['weight'=>0],['weight'=>null],[]] as $staff){
 UpgradeStaff::$data=$staff;
 $old=bare('app\\api\\controller\\health\\ArchiveUpgradeBaseline')->info()->getData();
 $new=bare('app\\api\\controller\\health\\Archive')->info()->getData();
 verifyUpgrade($new['data']['weight_status']['latest_weight']===($staff['weight']??0),'staff weight overrides status');
 verifyUpgrade($new['data']['body']['weight']===90,'body measurement remains separate');
 $old['data']['weight_status']['latest_weight']=$staff['weight']??0;
 verifyUpgrade($old===$new,'all other archive fields unchanged');
}
UpgradeWeightService::$data=[];UpgradeStaff::$data=['weight'=>'62.3'];
$new=bare('app\\api\\controller\\health\\Archive')->info()->getData();
verifyUpgrade($new['data']['weight_status']['latest_weight']==='62.3','empty weight status can use staff profile');
echo "PASS controller dynamic: $checks assertions; real baseline/target controllers with read boundaries replaced\n";
