<?php
declare(strict_types=1);
namespace think {
    final class Config {public static $type='mysql';public static function get($key){return $key==='database.type'?self::$type:null;}}
}
namespace {
$file=$argv[1]??'';if(!is_file($file)){exit(78);}require $file;
final class VersionRowsSource
{
    private $rows;public function __construct($rows){$this->rows=$rows;}
    public function inquiry(...$args){return $this->rows;}public function inquiryCount(...$args){return count($this->rows);}public function read(...$args){return $this->rows[0]??null;}
}
$logic=(new ReflectionClass(\app\p\logic\Equipment::class))->newInstanceWithoutConstructor();$n=0;
$assert=static function($a,$b,string $label)use(&$n):void{$n++;if(gettype($a)!==gettype($b)||$a!==$b){throw new RuntimeException($label);}};
foreach(['mysql','app\\cores\\database\\Dm'] as $driver){\think\Config::$type=$driver;
foreach(['2026-01-02 03:04:05.000000'=>'2026-01-02 03:04:05','2026-01-02 03:04:05.0'=>'2026-01-02 03:04:05','2026-01-02 03:04:05'=>'2026-01-02 03:04:05','2026-01-02 03:04:05.000001'=>'2026-01-02 03:04:05.000001','not-a-date'=>'not-a-date','2026-02-30 03:04:05.000000'=>'2026-02-30 03:04:05.000000','2026-01-02 24:04:05.000000'=>'2026-01-02 24:04:05.000000','2026-01-02 03:60:05.000000'=>'2026-01-02 03:60:05.000000','2026-01-02 03:04:60.000000'=>'2026-01-02 03:04:60.000000'] as $input=>$wanted){
    if($driver==='mysql'){$wanted=$input;}
    $row=['id'=>1,'create_time'=>$input,'update_time'=>'2026-01-02 03:04:05.000000','content'=>'中文','is_renew'=>1];$logic->VersionModel=new VersionRowsSource([$row]);
    $r=$logic->versionRead('synthetic');$assert($wanted,$r['create_time'],'versionRead.create_time');$assert($row['update_time'],$r['update_time'],'other timestamp untouched');$assert(1,$r['id'],'id unchanged');
    $list=$logic->versionList([],1,5,[]);$assert($wanted,$list['row'][0]['create_time'],'versionList.create_time');$assert(1,$list['total'],'total type');$assert('中文',$list['row'][0]['content'],'text unchanged');
}
$logic->VersionModel=new VersionRowsSource([['id'=>1,'create_time'=>null]]);$assert(null,$logic->versionRead('x')['create_time'],'NULL preserved');
$logic->VersionModel=new VersionRowsSource([['id'=>1]]);$assert(['id'=>1],$logic->versionRead('x'),'missing field not fabricated');
$logic->VersionModel=new VersionRowsSource([]);$assert(null,$logic->versionRead('missing'),'missing UUID unchanged');$assert(['row'=>[],'total'=>0],$logic->versionList([],1,5,[]),'empty list preserved');
}
echo json_encode(['assertions'=>$n,'passed'=>true,'database_queries'=>0,'real_public_methods'=>['versionList','versionRead']]),PHP_EOL;
}
