1, 'latest_version' => '0.2.0', 'min_version' => '0.1.5', 'force_update' => 0, 'title' => '医生工作站 0.2.0', 'notes' => '稳定性更新', 'packages' => [ 'windows_x64' => [ 'url' => 'https://cdn.example.com/DoctorWorkstation-Windows-x64-0.2.0.zip', 'sha256' => $sha, 'size' => 123, 'filename' => 'DoctorWorkstation-Windows-x64-0.2.0.zip', ], ], ]; $optional = DesktopWorkstationLogic::evaluate($config, '0.1.8', 'windows', 'x64'); desktopUpdateExpect($optional['has_update'] === true, 'newer published version is an update'); desktopUpdateExpect($optional['force'] === false, 'force stays off when above min version'); desktopUpdateExpect($optional['can_install'] === true, 'hashed package can be installed'); desktopUpdateExpect( is_array($optional['package']) && $optional['package']['sha256'] === $sha, 'matching windows package is returned' ); $forcedByMin = DesktopWorkstationLogic::evaluate($config, '0.1.0', 'windows', 'x64'); desktopUpdateExpect($forcedByMin['force'] === true, 'below min version forces upgrade'); $config['force_update'] = 1; $forcedAll = DesktopWorkstationLogic::evaluate($config, '0.1.9', 'windows', 'x64'); desktopUpdateExpect($forcedAll['force'] === true, 'force_update blocks every older client'); $current = DesktopWorkstationLogic::evaluate($config, '0.2.0', 'windows', 'x64'); desktopUpdateExpect($current['has_update'] === false, 'current latest version is not an update'); $macosMissing = DesktopWorkstationLogic::evaluate($config, '0.1.0', 'macos', 'arm64'); desktopUpdateExpect($macosMissing['has_update'] === true, 'other platforms still see the new version'); desktopUpdateExpect($macosMissing['can_install'] === false, 'missing platform package cannot auto-install'); desktopUpdateExpect($macosMissing['force'] === false, 'force requires an installable package'); $disabled = $config; $disabled['enabled'] = 0; $quiet = DesktopWorkstationLogic::evaluate($disabled, '0.1.0', 'windows', 'x64'); desktopUpdateExpect($quiet['has_update'] === false, 'disabled detection never prompts'); $controller = file_get_contents(dirname(__DIR__) . '/app/adminapi/controller/setting/DesktopWorkstationController.php'); desktopUpdateExpect(is_string($controller), 'controller source is readable'); desktopUpdateExpect( str_contains($controller, "public array \$notNeedLogin = ['check']") && str_contains($controller, 'public function check()') && str_contains($controller, 'DesktopWorkstationLogic::check('), 'check action is public and delegates to logic' ); $adminView = file_get_contents(dirname(__DIR__, 2) . '/admin/src/views/setting/desktop_workstation/index.vue'); desktopUpdateExpect(is_string($adminView), 'admin view source is readable'); desktopUpdateExpect( str_contains($adminView, 'setting.desktop_workstation/setConfig') && str_contains($adminView, 'force_update'), 'admin page can save force-update configuration' ); $migration = file_get_contents( dirname(__DIR__) . '/sql/1.9.20260821/add_desktop_workstation_update_menu.sql' ); desktopUpdateExpect(is_string($migration), 'menu migration is readable'); desktopUpdateExpect( substr_count($migration, "WHERE `perms` = 'setting.desktop_workstation/getConfig'") >= 1 && str_contains($migration, 'setting.desktop_workstation/setConfig') && str_contains($migration, 'setting/desktop_workstation/index'), 'menu registration is idempotent and points at the admin view' ); echo "Desktop workstation update contract: OK\n";