From 37d26b6345e2a55bc6feeb1a604154a99bf497bb Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Fri, 29 Dec 2023 16:19:50 +0800 Subject: [PATCH] + Add the test file of storeModel::pickHighestVersion. --- module/store/model.php | 4 ++-- .../store/test/model/pickhighestversion.php | 24 +++++++++++++++++++ module/store/test/store.class.php | 15 ++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 module/store/test/model/pickhighestversion.php diff --git a/module/store/model.php b/module/store/model.php index a73717d428..83bec81c13 100644 --- a/module/store/model.php +++ b/module/store/model.php @@ -217,10 +217,10 @@ class storeModel extends model * Pick highest version from version list and compared version. * * @param array $versionList - * @access private + * @access public * @return object|null */ - private function pickHighestVersion(array $versionList): object|null + public function pickHighestVersion(array $versionList): object|null { if(empty($versionList)) return null; diff --git a/module/store/test/model/pickhighestversion.php b/module/store/test/model/pickhighestversion.php new file mode 100644 index 0000000000..da5161b1b3 --- /dev/null +++ b/module/store/test/model/pickhighestversion.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +pickHighestVersion(). +cid=1 + +- 不指定ID获取最新版本属性version @2023.12.2801 +- 指定ID获取最新版本属性version @2023.12.2801 + +*/ + +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/store.class.php'; + +zdTable('user')->gen(5); +su('admin'); + +$appIdList = array(0, 29); + +$store = new storeTest(); +r($store->pickHighestVersionTest('2023.11.2301', $appIdList[0])) && p('version') && e('2023.12.2801'); //不指定ID获取最新版本 +r($store->pickHighestVersionTest('2023.11.2301', $appIdList[1])) && p('version') && e('2023.12.2801'); //指定ID获取最新版本 diff --git a/module/store/test/store.class.php b/module/store/test/store.class.php index 01ccef1caf..370065b1a9 100644 --- a/module/store/test/store.class.php +++ b/module/store/test/store.class.php @@ -218,4 +218,19 @@ class storeTest if($recPerPage != 20 && !empty($result)) return count($result->articles); return 'Success'; } + + /** + * 测试从版本列表中选择最高版本并进行比较。 + * Test pick highest version from version list and compared version. + * + * @param array $versionList + * @access public + * @return object|null + */ + public function pickHighestVersionTest(string $currentVersion, int $appID) + { + $versionList = $this->getUpgradableVersions($currentVersion, $appID); + $result = $this->pickHighestVersion($versionList); + return $result; + } }