+ Add the test file of storeModel::pickHighestVersion.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
|
||||
title=测试 storeModel->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获取最新版本
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user