<?php
declare(strict_types=1);
// Real public methods, fake read-only result sources; HTTP is tested separately.
$file=$argv[1]??'';if(!is_file($file)){exit(78);}function getImgFullPath($path=''){return $path===''?'':'/test/'.$path;}
require $file;
final class MenuLookupRows
{
    private $rows;public function __construct(array $rows){$this->rows=$rows;}
    public function where($v){return $this;}public function field($v){return $this;}public function order(...$v){return $this;}public function select(){return $this;}public function toArray(){return $this->rows;}
    public function getMenuInof(...$v){return $this->rows;}
}
$logic=(new ReflectionClass(\app\p\logic\DateMenu::class))->newInstanceWithoutConstructor();$n=0;
$set=static function(string $name,$value)use($logic):void{$p=new ReflectionProperty($logic,$name);$p->setAccessible(true);$p->setValue($logic,$value);};
$assert=static function($expected,$actual,string $label)use(&$n):void{$n++;if(gettype($expected)!==gettype($actual)||$expected!==$actual){throw new RuntimeException($label);}};
$fields=['weight','total_energy','energy','total_carbohydrate','carbohydrate','total_protein','protein','total_fat','fat','total_va','total_ve','total_dietary_fiber','total_retinol','total_vb1','total_vb2','total_vpp','total_sodium','total_calcium','total_iron','total_vc','total_tenieratene','total_potassium','total_magnesium','total_manganese','total_zinc','total_cuprum','total_phosphorus','total_selenium'];
foreach([0,12.34,999.99] as $v){$row=['weight'=>$v,'power'=>12.0,'carbohydrate'=>0.0,'protein'=>100000000,'fat'=>2.0,'unit'=>1,'category'=>2,'price'=>9.75,'nullable'=>null,'file_path'=>''];$set('dishesModel',new MenuLookupRows([$row]));$out=$logic->getDishes(2)['data'][0];$assert(number_format((float)$v,2,'.',''),$out['weight'],'lookup.weight');foreach(['power'=>'12','carbohydrate'=>'0','protein'=>'100000000','fat'=>'2'] as $f=>$value){$assert($value,$out[$f],'lookup.'.$f);}$assert(1,$out['unit'],'integer untouched');$assert(9.75,$out['price'],'FLOAT untouched');$assert(null,$out['nullable'],'NULL untouched');}
foreach([0,12.34,99999999.99] as $v){$row=array_fill_keys($fields,$v);$row['weight']=min((float)$v,999.99);$row+=['unit'=>1,'category'=>2,'price'=>9.75,'unknown'=>12.34];$set('recipesModel',new MenuLookupRows([$row]));$out=$logic->RecipeInfo('2026-01-01',1)['data'][0];foreach($fields as $f){$assert(number_format((float)$row[$f],2,'.',''),$out[$f],'recipe.'.$f);}$assert(1,$out['unit'],'integer untouched');$assert(9.75,$out['price'],'FLOAT untouched');$assert(12.34,$out['unknown'],'unknown untouched');}
$row=array_fill_keys($fields,'9007199254740993.000000000000000000');$row['weight']=null;$set('recipesModel',new MenuLookupRows([$row]));$out=$logic->RecipeInfo('2026-01-01',1)['data'][0];foreach($fields as $f){$assert($row[$f],$out[$f],'source string/NULL never recast');}
$set('recipesModel',new MenuLookupRows([]));$assert([],$logic->RecipeInfo('2026-01-01',1)['data'],'empty unchanged');
echo json_encode(['assertions'=>$n,'passed'=>true,'database_queries'=>0,'real_public_methods'=>['getDishes','RecipeInfo']]),PHP_EOL;
