* [refac] Refactor test lib classes.

This commit is contained in:
liugang
2026-01-16 14:40:55 +08:00
parent e05ac8f5a5
commit ff3ec0cb7f
85 changed files with 1220 additions and 9947 deletions
@@ -42,7 +42,7 @@ r($actionTest->getDynamicByProductTest($productID, $accountList[1])) && p() && e
r($actionTest->getDynamicByProductTest($productID, $accountList[2])) && p() && e('2'); // 查找用户dev17动态
r($actionTest->getDynamicByProductTest($productID, $accountList[3])) && p() && e('2'); // 查找用户test18动态
$actionTest->objectModel->dao->update(TABLE_ACTIONPRODUCT)->set('product')->eq('1')->where('action')->eq('33')->exec();
$actionTest->instance->dao->update(TABLE_ACTIONPRODUCT)->set('product')->eq('1')->where('action')->eq('33')->exec();
r($actionTest->getDynamicByProductTest($productID, $accountList[3], $typeList[1])) && p() && e('1'); // 查找今天的动态
r($actionTest->getDynamicByProductTest($productID, $accountList[1], $typeList[2])) && p() && e('0'); // 查找昨天的动态
+2 -2
View File
@@ -30,5 +30,5 @@ $action = new actionModelTest();
r($action->getFirstActionTest()) && p('id,objectID,objectType,action,extra') && e('1,1,product,common,1'); // 测试获取对象类型 story 对象ID 1 的动态信息
$action->objectModel->dao->delete()->from(TABLE_ACTION)->exec();
r($action->getFirstActionTest()) && p() && e('0'); // 没有动态数据
$action->instance->dao->delete()->from(TABLE_ACTION)->exec();
r($action->getFirstActionTest()) && p() && e('0'); // 没有动态数据
+3 -3
View File
@@ -2,7 +2,7 @@
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
include dirname(__FILE__, 4) . '/file/test/lib/file.unittest.class.php';
include dirname(__FILE__, 4) . '/file/test/lib/model.class.php';
su('admin');
zenData('action')->gen(2);
@@ -29,8 +29,8 @@ $commentList = array('备注1', '备注2', '<p><img src="uupdatecomment.php?m=f
$uidList = array('', uniqid());
$action = new actionModelTest();
$file = new fileTest();
$file = new fileModelTest();
r($action->updateCommentTest($actionIDList[0], $commentList[0], $uidList[0])) && p('comment') && e('备注1'); // 测试更新action 1的备注, 备注被成功更新为备注1
r($action->updateCommentTest($actionIDList[1], $commentList[1], $uidList[1])) && p('comment') && e('备注2'); // 测试更新action 2的备注, 备注被成功更新为备注2
r($file->getByIdTest(1)) && p('objectType;objectID;name') && e('story;2;文件标题1'); // 查看更新后的文件
r($file->getByIdTest(1)) && p('objectType;objectID;name') && e('story;2;文件标题1'); // 查看更新后的文件
+1 -1
View File
@@ -98,4 +98,4 @@ $devMenu = array(
'link' => '',
'disabled' => true
);
r($adminTest->setSubMenuTest('dev', $devMenu)) && p('subMenu,editor,link') && e('Editor|editor|index|');
r($adminTest->setSubMenuTest('dev', $devMenu)) && p('subMenu,editor,link') && e('Editor|editor|index|');
+1 -1
View File
@@ -422,7 +422,7 @@ class aiModelTest extends baseTest
*/
public function standardizeParamsTest($data = null)
{
$result = $this->invokeArgs(i'standardizeParams', [$data]);
$result = $this->invokeArgs('standardizeParams', [$data]);
if(dao::isError()) return dao::getError();
return $result;
}
+10 -71
View File
@@ -15,78 +15,14 @@ cid=15006
*/
// 尝试包含框架,如果失败则使用模拟版本
$useFramework = true;
try {
// 抑制错误输出
ob_start();
error_reporting(0);
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 用户登录(选择合适角色)
su('admin');
// 4. 创建测试实例(变量名与模块名一致)
$aiTest = new aiModelTest();
ob_end_clean();
error_reporting(E_ALL);
} catch (Exception $e) {
ob_end_clean();
$useFramework = false;
} catch (Error $e) {
ob_end_clean();
$useFramework = false;
} catch (Throwable $e) {
ob_end_clean();
$useFramework = false;
}
// 如果框架初始化失败,使用简化版本
if (!$useFramework || !isset($aiTest)) {
// 模拟aiTest类
class aiTest
{
public function converseForJSONTest($model = null, $messages = array(), $schema = null, $options = array())
{
// 完全模拟converseForJSON方法,不依赖任何外部系统
// 1. 检查模型参数
if(!is_numeric($model)) {
return false; // 非数字模型ID
}
$modelId = intval($model);
if($modelId <= 0) {
return false; // 零或负数模型ID
}
if($modelId == 999) {
return false; // 不存在的模型ID
}
// 2. 检查messages参数
if(!is_array($messages) || empty($messages)) {
return false;
}
// 3. 检查schema参数
if(!is_object($schema) || empty($schema)) {
return false;
}
// 4. 即使参数有效,在测试环境中也会因为网络/配置问题而失败
return false;
}
}
$aiTest = new aiModelTest();
}
// 准备测试数据
// 3. 准备测试数据
$validMessages = array(
(object)array('role' => 'user', 'content' => 'Generate a user profile with name and age')
);
@@ -103,9 +39,12 @@ $validSchema = (object)array(
$invalidSchema = array();
$emptyMessages = array();
// 4. 创建测试实例(变量名与模块名一致)
$aiTest = new aiModelTest();
// 5. 强制要求:必须包含至少5个测试步骤
r($aiTest->converseForJSONTest(1, $validMessages, $validSchema)) && p() && e('0'); // 步骤1:有效模型ID、有效消息、有效schema
r($aiTest->converseForJSONTest(999, $validMessages, $validSchema)) && p() && e('0'); // 步骤2:无效模型ID、有效消息、有效schema
r($aiTest->converseForJSONTest(1, $emptyMessages, $validSchema)) && p() && e('0'); // 步骤3:有效模型ID、空消息数组、有效schema
r($aiTest->converseForJSONTest(1, $validMessages, $invalidSchema)) && p() && e('0'); // 步骤4:有效模型ID、有效消息、无效schema
r($aiTest->converseForJSONTest(-1, $validMessages, $validSchema)) && p() && e('0'); // 步骤5:负数模型ID、有效消息、有效schema
r($aiTest->converseForJSONTest(-1, $validMessages, $validSchema)) && p() && e('0'); // 步骤5:负数模型ID、有效消息、有效schema
+24 -407
View File
@@ -35,9 +35,7 @@ class apiModelTest extends baseTest
$this->instance->deleteRelease($id);
$objects = $this->instance->getRelease($libID);
if(dao::isError()) return dao::getError();
return $objects;
}
@@ -52,7 +50,6 @@ class apiModelTest extends baseTest
{
$result = $this->instance->getApiStatusText($status);
if(dao::isError()) return dao::getError();
return $result;
}
@@ -66,14 +63,11 @@ class apiModelTest extends baseTest
*/
public function createTest($params, $confirm = true)
{
global $tester;
$_POST = $params;
$_POST = $params;
$objects = $this->instance->create($params['lib']);
if(dao::isError()) return dao::getError();
if($confirm) $tester->dao->delete()->from(TABLE_API)->where('id')->eq($objects->id)->exec();
if($confirm) $this->instance->dao->delete()->from(TABLE_API)->where('id')->eq($objects->id)->exec();
return $objects;
}
@@ -89,7 +83,6 @@ class apiModelTest extends baseTest
{
$result = $this->instance->createStruct($data);
if(dao::isError()) return dao::getError();
return $result;
}
@@ -104,7 +97,6 @@ class apiModelTest extends baseTest
{
$result = $this->instance->updateStruct($formData);
if(dao::isError()) return dao::getError();
return $result;
}
@@ -119,14 +111,11 @@ class apiModelTest extends baseTest
*/
public function updateTest($apiID, $params, $confirm = true)
{
global $tester;
$_POST = $params;
$_POST = $params;
$objects = $this->instance->update($apiID);
if(dao::isError()) return dao::getError();
if($confirm) $tester->dao->delete()->from(TABLE_API)->where('id')->eq($apiID)->exec();
if($confirm) $this->instance->dao->delete()->from(TABLE_API)->where('id')->eq($apiID)->exec();
return $objects;
}
@@ -141,13 +130,10 @@ class apiModelTest extends baseTest
*/
public function getStructListByLibIDTest($id, $confirm = true)
{
global $tester;
$objects = $this->instance->getStructListByLibID($id);
if(dao::isError()) return dao::getError();
if($confirm) $tester->dao->delete()->from(TABLE_APISTRUCT)->where('id')->eq($objects['0']->id)->exec();
if($confirm) $this->instance->dao->delete()->from(TABLE_APISTRUCT)->where('id')->eq($objects['0']->id)->exec();
return $objects;
}
@@ -162,13 +148,10 @@ class apiModelTest extends baseTest
*/
public function getStructByIDTest($id, $confirm = true)
{
global $tester;
$objects = $this->instance->getStructByID($id);
if(dao::isError()) return dao::getError();
if($confirm) $tester->dao->delete()->from(TABLE_APISTRUCT)->where('id')->eq($objects->id)->exec();
if($confirm) $this->instance->dao->delete()->from(TABLE_APISTRUCT)->where('id')->eq($objects->id)->exec();
return $objects;
}
@@ -186,7 +169,6 @@ class apiModelTest extends baseTest
public function getReleaseTest($libID = 0, $type = '', $param = 0, $confirm = true)
{
$objects = $this->instance->getRelease($libID = 0, $type = '', $param = 0);
if(dao::isError()) return dao::getError();
if($confirm) $this->instance->deleteRelease($objects->id);
@@ -206,7 +188,6 @@ class apiModelTest extends baseTest
public function getReleaseListByApiTest($libID, $id = 0, $confirm = true)
{
$objects = $this->instance->getReleaseListByApi($libID);
if(dao::isError()) return dao::getError();
if($confirm) $this->instance->deleteRelease($objects[$id]->id);
@@ -226,9 +207,7 @@ class apiModelTest extends baseTest
public function getLibByIdTest($id, $version = 0, $release = 0)
{
$objects = $this->instance->getLibById($id, $version = 0, $release = 0);
if(dao::isError()) return dao::getError();
return $objects;
}
@@ -243,13 +222,10 @@ class apiModelTest extends baseTest
*/
public function getApiListByReleaseTest($release, $where = '1 = 1 ')
{
global $tester;
$objects = $this->instance->getApiListByRelease($release, $where = '1 = 1 ');
if(dao::isError()) return dao::getError();
foreach($release->snap['apis'] as $api) $tester->dao->delete()->from(TABLE_API)->where('id')->eq($api['id'])->exec();
foreach($release->snap['apis'] as $api) $this->instance->dao->delete()->from(TABLE_API)->where('id')->eq($api['id'])->exec();
$this->instance->deleteRelease($release->id);
return $objects;
@@ -267,9 +243,7 @@ class apiModelTest extends baseTest
public function getListByModuleIdTest($libID = 0, $moduleID = 0, $release = 0)
{
$objects = $this->instance->getListByModuleId($libID, $moduleID, $release);
if(dao::isError()) return dao::getError();
return current($objects);
}
@@ -285,9 +259,7 @@ class apiModelTest extends baseTest
public function getStructListByReleaseTest($release, $where = '1 = 1 ', $orderBy = 'id')
{
$objects = $this->instance->getStructListByRelease($release, $where = '1 = 1 ', $orderBy = 'id');
if(dao::isError()) return dao::getError();
return $objects;
}
@@ -302,19 +274,11 @@ class apiModelTest extends baseTest
*/
public function createDemoLibTest($name, $baseUrl, $currentAccount)
{
global $tester;
$reflection = new ReflectionClass($this->instance);
$method = $reflection->getMethod('createDemoLib');
$method->setAccessible(true);
$libID = $method->invoke($this->instance, $name, $baseUrl, $currentAccount);
$libID = $this->invokeArgs('createDemoLib', [$name, $baseUrl, $currentAccount]);
if(dao::isError()) return dao::getError();
$lib = $tester->dao->select('*')->from(TABLE_DOCLIB)->where('id')->eq($libID)->fetch();
$tester->dao->delete()->from(TABLE_DOCLIB)->where('id')->eq($libID)->exec();
$lib = $this->instance->dao->select('*')->from(TABLE_DOCLIB)->where('id')->eq($libID)->fetch();
$this->instance->dao->delete()->from(TABLE_DOCLIB)->where('id')->eq($libID)->exec();
return $lib;
}
@@ -330,16 +294,8 @@ class apiModelTest extends baseTest
*/
public function createDemoStructTest($libID, $version, $currentAccount)
{
global $tester;
$reflection = new ReflectionClass($this->instance);
$method = $reflection->getMethod('createDemoStruct');
$method->setAccessible(true);
$result = $method->invoke($this->instance, $libID, $version, $currentAccount);
$result = $this->invokeArgs('createDemoStruct', [$libID, $version, $currentAccount]);
if(dao::isError()) return dao::getError();
return $result;
}
@@ -353,16 +309,8 @@ class apiModelTest extends baseTest
*/
public function createDemoStructSpecTest($version, $currentAccount)
{
global $tester;
$reflection = new ReflectionClass($this->instance);
$method = $reflection->getMethod('createDemoStructSpec');
$method->setAccessible(true);
$result = $method->invoke($this->instance, $version, $currentAccount);
$result = $this->invokeArgs('createDemoStructSpec', [$version, $currentAccount]);
if(dao::isError()) return dao::getError();
return $result;
}
@@ -376,16 +324,8 @@ class apiModelTest extends baseTest
*/
public function createDemoModuleTest($libID, $version)
{
global $tester;
$reflection = new ReflectionClass($this->instance);
$method = $reflection->getMethod('createDemoModule');
$method->setAccessible(true);
$result = $method->invoke($this->instance, $libID, $version);
$result = $this->invokeArgs('createDemoModule', [$libID, $version]);
if(dao::isError()) return dao::getError();
return $result;
}
@@ -401,16 +341,8 @@ class apiModelTest extends baseTest
*/
public function createDemoApiTest($libID, $version, $moduleMap, $currentAccount)
{
global $tester;
$reflection = new ReflectionClass($this->instance);
$method = $reflection->getMethod('createDemoApi');
$method->setAccessible(true);
$result = $method->invoke($this->instance, $libID, $version, $moduleMap, $currentAccount);
$result = $this->invokeArgs('createDemoApi', [$libID, $version, $moduleMap, $currentAccount]);
if(dao::isError()) return dao::getError();
return $result;
}
@@ -426,34 +358,13 @@ class apiModelTest extends baseTest
*/
public function createDemoApiSpecTest($version, $apiMap, $moduleMap, $currentAccount)
{
global $tester;
// 先检查版本文件是否存在,避免后续的file_get_contents错误
$demoDataFile = $this->instance->app->getAppRoot() . 'db' . DS . 'api' . DS . $version . DS . 'apispec';
if(!file_exists($demoDataFile)) return 0;
try
{
// 先检查版本文件是否存在,避免后续的file_get_contents错误
$demoDataFile = $this->instance->app->getAppRoot() . 'db' . DS . 'api' . DS . $version . DS . 'apispec';
if (!file_exists($demoDataFile)) {
return 0;
}
$reflection = new ReflectionClass($this->instance);
$method = $reflection->getMethod('createDemoApiSpec');
$method->setAccessible(true);
$result = $method->invoke($this->instance, $version, $apiMap, $moduleMap, $currentAccount);
if(dao::isError()) return dao::getError();
return $result ? 1 : 0;
}
catch(Exception $e)
{
return 0;
}
catch(TypeError $e)
{
return 0;
}
$result = $this->invokeArgs('createDemoApiSpec', [$version, $apiMap, $moduleMap, $currentAccount]);
if(dao::isError()) return dao::getError();
return $result ? 1 : 0;
}
/**
@@ -465,9 +376,7 @@ class apiModelTest extends baseTest
public function getGroupedObjectsTest()
{
$result = $this->instance->getGroupedObjects();
if(dao::isError()) return dao::getError();
return $result;
}
@@ -484,23 +393,15 @@ class apiModelTest extends baseTest
*/
public function buildSearchFormTest($lib, $queryID, $actionURL, $libs = array(), $type = '')
{
global $tester;
// 备份原始配置
$originalConfig = isset($tester->config->api->search) ? $tester->config->api->search : null;
$originalConfig = isset($this->instance->config->api->search) ? $this->instance->config->api->search : null;
// 执行方法
$this->instance->buildSearchForm($lib, $queryID, $actionURL, $libs, $type);
if(dao::isError()) return dao::getError();
// 返回设置后的搜索配置
$result = array(
'module' => isset($tester->config->api->search['module']) ? $tester->config->api->search['module'] : '',
'queryID' => isset($tester->config->api->search['queryID']) ? $tester->config->api->search['queryID'] : '',
'actionURL' => isset($tester->config->api->search['actionURL']) ? $tester->config->api->search['actionURL'] : '',
'libValues' => isset($tester->config->api->search['params']['lib']['values']) ? $tester->config->api->search['params']['lib']['values'] : array()
);
$result = $this->instance->config->api->search;
// 恢复原始配置
if($originalConfig !== null) $tester->config->api->search = $originalConfig;
@@ -517,14 +418,8 @@ class apiModelTest extends baseTest
*/
public function getApiSpecByDataTest($data)
{
$reflection = new ReflectionClass($this->instance);
$method = $reflection->getMethod('getApiSpecByData');
$method->setAccessible(true);
$result = $method->invoke($this->instance, $data);
$result = $this->invokeArgs('getApiSpecByData', [$data]);
if(dao::isError()) return dao::getError();
return $result;
}
@@ -537,14 +432,8 @@ class apiModelTest extends baseTest
*/
public function getApiStructSpecByDataTest($data)
{
$reflection = new ReflectionClass($this->instance);
$method = $reflection->getMethod('getApiStructSpecByData');
$method->setAccessible(true);
$result = $method->invoke($this->instance, $data);
$result = $this->invokeArgs('getApiStructSpecByData', [$data]);
if(dao::isError()) return dao::getError();
return $result;
}
@@ -558,282 +447,10 @@ class apiModelTest extends baseTest
public function getTypeListTest($libID)
{
$result = $this->instance->getTypeList($libID);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test generateLibsDropMenu method.
*
* @param object $lib
* @param int $version
* @access public
* @return array|string
*/
public function generateLibsDropMenuTest($lib, $version = 0)
{
global $tester;
// 加载api控制器类、模型类和apiZen类
require_once dirname(__FILE__, 3) . '/control.php';
require_once dirname(__FILE__, 3) . '/model.php';
require_once dirname(__FILE__, 3) . '/zen.php';
// 创建apiZen实例
$apiZen = new apiZen();
// 为apiZen对象注入必要的依赖
$apiZen->config = $tester->config;
$apiZen->session = $tester->session;
$apiZen->app = $tester->app;
$apiZen->lang = $tester->lang;
// 使用反射调用protected方法
$reflection = new ReflectionClass($apiZen);
$method = $reflection->getMethod('generateLibsDropMenu');
$method->setAccessible(true);
$result = $method->invoke($apiZen, $lib, $version);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test parseDocSpaceParam method.
*
* @param array $libs
* @param int $libID
* @param string $type
* @param int $objectID
* @param int $moduleID
* @param string $spaceType
* @param int $release
* @param string $cookieData
* @access public
* @return array
*/
public function parseDocSpaceParamTest(array $libs, int $libID, string $type, int $objectID, int $moduleID, string $spaceType, int $release, string $cookieData = '')
{
global $tester;
// 加载api控制器类、模型类和apiZen类
require_once dirname(__FILE__, 3) . '/control.php';
require_once dirname(__FILE__, 3) . '/model.php';
require_once dirname(__FILE__, 3) . '/zen.php';
// 创建apiZen实例并模拟cookie属性
$apiZen = new apiZen();
// 为apiZen对象注入必要的依赖
$apiZen->config = $tester->config;
$apiZen->session = $tester->session;
$apiZen->app = $tester->app;
$apiZen->lang = $tester->lang;
// 创建cookie对象
$apiZen->cookie = new stdClass();
if(!empty($cookieData))
{
$apiZen->cookie->docSpaceParam = $cookieData;
}
// 创建view对象
$apiZen->view = new stdClass();
// 模拟doc模块以避免复杂的依赖关系
$apiZen->doc = new stdClass();
$apiZen->doc->setMenuByType = function($type, $objectID, $libID) use ($libs) {
$object = null;
$objectDropdown = array();
return array($libs, $libID, $object, $objectID, $objectDropdown);
};
$apiZen->doc->getLibTree = function($libID, $libs, $type, $moduleID = 0, $objectID = 0, $browseType = '', $param = '') {
return array('tree' => 'mock_tree_data');
};
// 模拟generateLibsDropMenu方法
$reflection = new ReflectionClass($apiZen);
$generateMethod = $reflection->getMethod('generateLibsDropMenu');
$generateMethod->setAccessible(true);
// 使用反射调用protected方法parseDocSpaceParam
$method = $reflection->getMethod('parseDocSpaceParam');
$method->setAccessible(true);
// 简单的测试:仅检查方法是否能正常设置view属性
try {
// 先模拟简单场景避免复杂依赖
if(!empty($cookieData)) {
$docParam = json_decode($cookieData);
if(isset($docParam) && !(in_array($docParam->type, array('product', 'project')) && $docParam->objectID == 0)) {
// 直接设置结果,模拟方法行为
$apiZen->view->type = $docParam->type;
$apiZen->view->objectType = $docParam->type;
$apiZen->view->objectID = $docParam->objectID;
$apiZen->view->libID = $docParam->libID;
$apiZen->view->moduleID = $docParam->moduleID;
$apiZen->view->spaceType = $docParam->type;
$apiZen->view->libTree = array('mock' => true);
$apiZen->view->objectDropdown = array('mock' => true);
} else {
// 默认情况
$apiZen->view->type = $type;
$apiZen->view->objectType = $type;
$apiZen->view->objectID = $objectID;
$apiZen->view->libID = $libID;
$apiZen->view->moduleID = $moduleID;
$apiZen->view->spaceType = $spaceType;
$apiZen->view->libTree = array('mock' => true);
$apiZen->view->objectDropdown = array('mock' => true);
}
} else {
// 默认情况
$apiZen->view->type = $type;
$apiZen->view->objectType = $type;
$apiZen->view->objectID = $objectID;
$apiZen->view->libID = $libID;
$apiZen->view->moduleID = $moduleID;
$apiZen->view->spaceType = $spaceType;
$apiZen->view->libTree = array('mock' => true);
$apiZen->view->objectDropdown = array('mock' => true);
}
} catch (Exception $e) {
return array('error' => $e->getMessage());
}
if(dao::isError()) return dao::getError();
// 返回view中设置的属性
return array(
'type' => isset($apiZen->view->type) ? $apiZen->view->type : '',
'objectType' => isset($apiZen->view->objectType) ? $apiZen->view->objectType : '',
'objectID' => isset($apiZen->view->objectID) ? $apiZen->view->objectID : 0,
'libID' => isset($apiZen->view->libID) ? $apiZen->view->libID : 0,
'moduleID' => isset($apiZen->view->moduleID) ? $apiZen->view->moduleID : 0,
'spaceType' => isset($apiZen->view->spaceType) ? $apiZen->view->spaceType : '',
'libTree' => isset($apiZen->view->libTree) && !empty($apiZen->view->libTree),
'objectDropdown' => isset($apiZen->view->objectDropdown) && !empty($apiZen->view->objectDropdown)
);
}
/**
* Test getMethod method.
*
* @param string $filePath
* @param string $ext
* @access public
* @return object|array
*/
public function getMethodTest(string $filePath, string $ext = '')
{
global $tester;
// 加载api控制器类、模型类和apiZen类
require_once dirname(__FILE__, 3) . '/control.php';
require_once dirname(__FILE__, 3) . '/model.php';
require_once dirname(__FILE__, 3) . '/zen.php';
// 创建apiZen实例
$apiZen = new apiZen();
// 为apiZen对象注入必要的依赖
$apiZen->config = $tester->config;
$apiZen->session = $tester->session;
$apiZen->app = $tester->app;
$apiZen->lang = $tester->lang;
// 使用反射调用protected方法
$reflection = new ReflectionClass($apiZen);
$method = $reflection->getMethod('getMethod');
$method->setAccessible(true);
try {
$result = $method->invoke($apiZen, $filePath, $ext);
if(dao::isError()) return dao::getError();
return $result;
} catch (Exception $e) {
return array('error' => $e->getMessage());
} catch (ReflectionException $e) {
return array('error' => 'ReflectionException: ' . $e->getMessage());
}
}
/**
* Test request method.
*
* @param string $moduleName
* @param string $methodName
* @param string $action
* @param array $postData
* @access public
* @return array
*/
public function requestTest(string $moduleName, string $methodName, string $action, array $postData = array())
{
global $tester;
// 加载api控制器类、模型类和apiZen类
require_once dirname(__FILE__, 3) . '/control.php';
require_once dirname(__FILE__, 3) . '/model.php';
require_once dirname(__FILE__, 3) . '/zen.php';
// 创建apiZen实例
$apiZen = new apiZen();
// 为apiZen对象注入必要的依赖
$apiZen->config = $tester->config;
$apiZen->session = $tester->session;
$apiZen->app = $tester->app;
$apiZen->lang = $tester->lang;
// 备份原始 $_POST 数据
$originalPost = $_POST;
// 设置测试用的 $_POST 数据
$_POST = $postData;
// 模拟 URL 构建过程,不实际调用 file_get_contents
$host = 'http://localhost'; // 模拟系统URL
$param = '';
if($action == 'extendModel')
{
if(!isset($_POST['noparam']))
{
foreach($_POST as $key => $value) $param .= ',' . $key . '=' . $value;
$param = ltrim($param, ',');
}
$url = $host . "/api-getModel-moduleName=$moduleName&methodName=$methodName&params=$param.json";
$url .= strpos($url, '?') === false ? '?' : '&';
$url .= 'zentaosid=test_session_id';
}
else
{
if(!isset($_POST['noparam']))
{
foreach($_POST as $key => $value) $param .= '&' . $key . '=' . $value;
$param = ltrim($param, '&');
}
$url = $host . "/$moduleName-$methodName" . ($param ? "-$param" : '') . ".json";
$url .= strpos($url, '?') === false ? '?' : '&';
$url .= 'zentaosid=test_session_id';
}
// 模拟响应内容,不实际进行HTTP请求
$content = 'mock_response_content';
// 恢复原始 $_POST 数据
$_POST = $originalPost;
if(dao::isError()) return dao::getError();
return array('url' => $url, 'content' => $content);
}
/**
* Test getPrivApis method.
*
+9 -90
View File
@@ -136,35 +136,9 @@ class backupModelTest extends baseTest
*/
public function getBackupListTest()
{
global $tester;
// 手动实现getBackupList的逻辑,避免复杂的类加载问题
$backupPath = $this->instance->getBackupPath();
$sqlFiles = glob("{$backupPath}*.sql*");
if(empty($sqlFiles)) return array();
$backupList = array();
foreach($sqlFiles as $file)
{
$fileName = basename($file);
$backupFile = new stdclass();
$backupFile->time = filemtime($file);
$backupFile->name = substr($fileName, 0, strpos($fileName, '.'));
$backupFile->files = array();
$backupFile->files[$file] = $this->instance->getBackupSummary($file);
$fileBackup = $this->instance->getBackupFile($backupFile->name, 'file');
if($fileBackup) $backupFile->files[$fileBackup] = $this->instance->getBackupSummary($fileBackup);
$codeBackup = $this->instance->getBackupFile($backupFile->name, 'code');
if($codeBackup) $backupFile->files[$codeBackup] = $this->instance->getBackupSummary($codeBackup);
$backupList[$backupFile->name] = $backupFile;
}
krsort($backupList);
return $backupList;
$result = $this->instance->getBackupList();
if(dao::isError()) return dao::getError();
return $result;
}
/**
@@ -177,20 +151,9 @@ class backupModelTest extends baseTest
*/
public function backupSQLTest($fileName = null, $reload = 'no')
{
// Mock implementation to simulate backupSQL behavior
if(empty($fileName))
{
$fileName = 'test_backup_' . time();
}
// Mock different scenarios based on input
if($fileName === 'fail_test')
{
return array('result' => 'fail', 'message' => 'Mock backup failed');
}
// Return success for normal cases
return array('result' => 'success');
$result = $this->instance->backupSQL($fileName, $reload);
if(dao::isError()) return dao::getError();
return $result;
}
/**
@@ -203,34 +166,9 @@ class backupModelTest extends baseTest
*/
public function backupFileTest($fileName = null, $reload = 'no')
{
// Mock implementation to simulate backupFile behavior
if(empty($fileName))
{
$fileName = 'test_backup_file_' . time();
}
// Mock different scenarios based on input
if($fileName === 'fail_test')
{
if($reload === 'yes')
{
return array('result' => 'fail', 'message' => 'Mock file backup failed');
}
else
{
// For reload=no, it would print error directly, but we mock as returning the message
return array('result' => 'fail', 'message' => 'Mock file backup failed');
}
}
// Mock nofile setting check - if nofile is in config, skip file backup
if(isset($this->instance->config->backup->setting) && str_contains($this->instance->config->backup->setting, 'nofile'))
{
return array('result' => 'success');
}
// Return success for normal cases
return array('result' => 'success');
$result = $this->instance->backupFile($fileName, $reload);
if(dao::isError()) return dao::getError();
return $result;
}
/**
@@ -334,23 +272,4 @@ class backupModelTest extends baseTest
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Clean up test directory.
*
* @param string $dir
* @access private
* @return void
*/
private function cleanupTestDir($dir)
{
if(!is_dir($dir)) return;
$files = glob($dir . '*');
foreach($files as $file)
{
if(is_file($file)) unlink($file);
}
rmdir($dir);
}
}
+21 -12
View File
@@ -31,11 +31,14 @@ class backupZenTest extends baseTest
*/
public function backupCodeTestWithNofile()
{
global $config;
$oldSetting = $config->backup->setting;
$config->backup->setting = 'nofile';
$oldSetting = $this->instance->config->backup->setting;
$this->instance->config->backup->setting = 'nofile';
$result = $this->invokeArgs('backupCode', ['test_nofile']);
$config->backup->setting = $oldSetting;
$this->instance->config->backup->setting = $oldSetting;
if(dao::isError()) return dao::getError();
return $result;
}
@@ -63,11 +66,14 @@ class backupZenTest extends baseTest
*/
public function backupFileTestWithNofile()
{
global $config;
$oldSetting = $config->backup->setting;
$config->backup->setting = 'nofile';
$oldSetting = $this->instance->config->backup->setting;
$this->instance->config->backup->setting = 'nofile';
$result = $this->invokeArgs('backupFile', ['test_nofile']);
$config->backup->setting = $oldSetting;
$this->instance->config->backup->setting = $oldSetting;
if(dao::isError()) return dao::getError();
return $result;
}
@@ -95,11 +101,14 @@ class backupZenTest extends baseTest
*/
public function backupSQLTestWithNosafe()
{
global $config;
$oldSetting = $config->backup->setting;
$config->backup->setting = 'nosafe';
$oldSetting = $this->instance->config->backup->setting;
$this->instance->config->backup->setting = 'nosafe';
$result = $this->invokeArgs('backupSQL', ['test_nosafe_' . time()]);
$config->backup->setting = $oldSetting;
$this->instance->config->backup->setting = $oldSetting;
if(dao::isError()) return dao::getError();
return $result;
}
+2
View File
@@ -1413,6 +1413,8 @@ class biModel extends model
$this->app->loadClass('sqlparser', true);
$parser = new sqlparser($sql);
if(!isset($this->lang->dataview)) $this->app->loadLang('dataview');
if($parser->statementsCount == 0)
{
if($mode == 'builder') return $this->lang->dataview->emptyBuilder;
+32
View File
@@ -682,6 +682,38 @@ class biModelTest extends baseTest
return $result;
}
/**
* Test saveLogs method.
*
* @param string $log
* @access public
* @return mixed
*/
public function saveLogsTest($log)
{
$logFile = $this->instance->getLogFile();
if(file_exists($logFile)) unlink($logFile);
$this->instance->saveLogs($log);
// 检查文件是否被创建
if(!file_exists($logFile)) return false;
// 读取文件内容进行验证
$content = file_get_contents($logFile);
// 清理测试文件
if(file_exists($logFile)) unlink($logFile);
return array(
'fileExists' => true,
'hasPhpHeader' => strpos($content, '<?php') === 0,
'hasDieStatement' => strpos($content, 'die();') !== false,
'hasLogContent' => strpos($content, $log) !== false,
'hasTimestamp' => preg_match('/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/', $content) === 1
);
}
/**
* Test parseSqlVars method.
*
+2 -2
View File
@@ -19,8 +19,8 @@ cid=15153
$biTest = new biModelTest();
r(method_exists($biTest->objectModel, 'checkDuckdbInstall')) && p() && e('1'); // 步骤1:验证方法存在性
r(method_exists($biTest->instance, 'checkDuckdbInstall')) && p() && e('1'); // 步骤1:验证方法存在性
r(is_array($biTest->checkDuckdbInstallTest())) && p() && e('1'); // 步骤2:检查返回值为数组类型
r(array_key_exists('loading', $biTest->checkDuckdbInstallTest()) && array_key_exists('ok', $biTest->checkDuckdbInstallTest()) && array_key_exists('fail', $biTest->checkDuckdbInstallTest())) && p() && e('1'); // 步骤3:验证返回结果包含所有必要字段
r(in_array($biTest->checkDuckdbInstallTest()['duckdb'], array('ok', 'fail', 'loading'))) && p() && e('1'); // 步骤4:验证返回状态值合法性
r(is_array($biTest->checkDuckdbInstallTest())) && p() && e('1'); // 步骤5:测试方法可重复调用
r(is_array($biTest->checkDuckdbInstallTest())) && p() && e('1'); // 步骤5:测试方法可重复调用
+7 -7
View File
@@ -21,31 +21,31 @@ $bi = new biModelTest();
// 测试用例1:简单SELECT语句
$sql1 = "SELECT 1 as id, 'test' as name";
$statement1 = $bi->objectModel->sql2Statement($sql1);
$statement1 = $bi->instance->sql2Statement($sql1);
$columnFields1 = array('id' => 'id', 'name' => 'name');
// 测试用例2:带别名的SELECT语句
// 测试用例2:带别名的SELECT语句
$sql2 = "SELECT 1 as user_id, 'admin' as user_name";
$statement2 = $bi->objectModel->sql2Statement($sql2);
$statement2 = $bi->instance->sql2Statement($sql2);
$columnFields2 = array('user_id' => 'user_id', 'user_name' => 'user_name');
// 测试用例3:空字段列表
$sql3 = "SELECT 'test' as value";
$statement3 = $bi->objectModel->sql2Statement($sql3);
$statement3 = $bi->instance->sql2Statement($sql3);
$columnFields3 = array();
// 测试用例4:多字段
$sql4 = "SELECT 1 as id, 'name' as title, 'desc' as description";
$statement4 = $bi->objectModel->sql2Statement($sql4);
$statement4 = $bi->instance->sql2Statement($sql4);
$columnFields4 = array('id' => 'id', 'title' => 'title', 'description' => 'description');
// 测试用例5:聚合函数
$sql5 = "SELECT COUNT(1) as total, 'admin' as role";
$statement5 = $bi->objectModel->sql2Statement($sql5);
$statement5 = $bi->instance->sql2Statement($sql5);
$columnFields5 = array('total' => 'total', 'role' => 'role');
r(count($bi->getParams4RebuildTest($sql1, $statement1, $columnFields1))) && p() && e(4); // 测试简单SELECT语句,检查返回数组包含4个元素
r($bi->getParams4RebuildTest($sql2, $statement2, $columnFields2)) && p('2:user_id') && e('user_id'); // 测试带别名的SELECT语句,验证字段映射处理
r(count($bi->getParams4RebuildTest($sql3, $statement3, $columnFields3))) && p() && e(4); // 测试空字段列表参数,确保方法能正常处理
r($bi->getParams4RebuildTest($sql4, $statement4, $columnFields4)) && p('2:description') && e('description'); // 测试复杂SELECT语句,验证多字段处理
r($bi->getParams4RebuildTest($sql5, $statement5, $columnFields5)) && p('2:total') && e('total'); // 测试聚合函数SQL,验证计算字段处理
r($bi->getParams4RebuildTest($sql5, $statement5, $columnFields5)) && p('2:total') && e('total'); // 测试聚合函数SQL,验证计算字段处理
+3 -3
View File
@@ -31,14 +31,14 @@ $biTest = new biModelTest();
// 测试用例1:简单SELECT语句
$sql1 = "SELECT id, account FROM zt_user LIMIT 1";
$statement1 = $biTest->objectModel->sql2Statement($sql1);
$statement1 = $biTest->instance->sql2Statement($sql1);
// 测试用例2:多字段SELECT语句
$sql2 = "SELECT id, account, realname FROM zt_user LIMIT 1";
$statement2 = $biTest->objectModel->sql2Statement($sql2);
$statement2 = $biTest->instance->sql2Statement($sql2);
r(count($biTest->prepareColumnsTest($sql1, $statement1, 'mysql'))) && p() && e('2'); // 测试简单SELECT语句,验证返回结果包含两个元素
r($biTest->prepareColumnsTest($sql1, $statement1, 'mysql')[0]) && p('id:name') && e('id'); // 测试简单SELECT语句,验证第一个元素columns包含id字段
r($biTest->prepareColumnsTest($sql1, $statement1, 'mysql')[0]) && p('account:name') && e('account'); // 测试简单SELECT语句,验证第一个元素columns包含account字段
r($biTest->prepareColumnsTest($sql1, $statement1, 'mysql')[1]) && p('id') && e('user'); // 测试简单SELECT语句,验证第二个元素relatedObjects包含id字段
r(count($biTest->prepareColumnsTest($sql2, $statement2, 'mysql')[0])) && p() && e('3'); // 测试多字段SELECT语句,验证columns字段数量
r(count($biTest->prepareColumnsTest($sql2, $statement2, 'mysql')[0])) && p() && e('3'); // 测试多字段SELECT语句,验证columns字段数量
@@ -9,7 +9,7 @@ title=测试 biModel::updateDownloadingTagFile();
timeout=0
cid=15218
- 执行$biTest->objectModel, 'updateDownloadingTagFile' @1
- 检查$biTest->instance是否存在updateDownloadingTagFile方法 @1
- 执行biTest模块的updateDownloadingTagFileTest方法 @1
- 执行biTest模块的updateDownloadingTagFileTest方法,参数是'file', 'create'), array @1
- 执行biTest模块的updateDownloadingTagFileTest方法,参数是'file', 'check'), array @1
@@ -21,10 +21,10 @@ cid=15218
$biTest = new biModelTest();
r(method_exists($biTest->objectModel, 'updateDownloadingTagFile')) && p() && e('1');
r(method_exists($biTest->instance, 'updateDownloadingTagFile')) && p() && e('1');
r(is_string($biTest->updateDownloadingTagFileTest())) && p() && e('1');
r(in_array($biTest->updateDownloadingTagFileTest('file', 'create'), array('ok', 'fail'))) && p() && e('1');
r(in_array($biTest->updateDownloadingTagFileTest('file', 'check'), array('ok', 'fail', 'loading'))) && p() && e('1');
r(in_array($biTest->updateDownloadingTagFileTest('file', 'remove'), array('ok', 'fail'))) && p() && e('1');
r(is_string($biTest->updateDownloadingTagFileTest('extension_dm', 'create'))) && p() && e('1');
r(is_string($biTest->updateDownloadingTagFileTest('extension_mysql', 'create'))) && p() && e('1');
r(is_string($biTest->updateDownloadingTagFileTest('extension_mysql', 'create'))) && p() && e('1');
+87 -1
View File
@@ -8,6 +8,34 @@ class blockModelTest extends baseTest
protected $moduleName = 'block';
protected $className = 'model';
/**
* Test create a block.
*
* @param object $block
* @access public
* @return int|false
*/
public function createTest($block)
{
$blockID = $this->objectModel->create($block);
if(dao::isError()) return dao::getError();
return $blockID;
}
/**
* Test getBlockInitStatus method.
*
* @param string $dashboard
* @access public
* @return bool
*/
public function getBlockInitStatusTest($dashboard)
{
$result = $this->objectModel->getBlockInitStatus($dashboard);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test getModelType4Projects method.
*
@@ -17,8 +45,66 @@ class blockModelTest extends baseTest
*/
public function getModelType4ProjectsTest($projectIdList = array())
{
$result = $this->invokeArgs('getModelType4Projects', array($projectIdList));
$result = $this->invokeArgs('getModelType4Projects', [$projectIdList]);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test getMyDashboard method.
*
* @param string $dashboard
* @access public
* @return object
*/
public function getMyDashboardTest(string $dashboard)
{
$result = $this->objectModel->getMyDashboard($dashboard);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test getSpecifiedBlockID method.
*
* @param string $dashboard
* @param string $module
* @param string $code
* @access public
* @return int|false
*/
public function getSpecifiedBlockIDTest(string $dashboard, string $module, string $code)
{
$result = $this->objectModel->getSpecifiedBlockID($dashboard, $module, $code);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test reset method.
*
* @param string $dashboard
* @access public
* @return bool
*/
public function resetTest(string $dashboard)
{
$result = $this->objectModel->reset($dashboard);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Update a block.
*
* @param object $block
* @access public
* @return int|false
*/
public function updateTest($block)
{
$blockID = $this->objectModel->update($block);
if(dao::isError()) return dao::getError();
return $blockID;
}
}
+244 -196
View File
@@ -17,10 +17,11 @@ class blockZenTest extends baseTest
*/
public function printBuildBlockTest(object $block)
{
$this->invokeArgs('printBuildBlock', array($block));
$this->invokeArgs('printBuildBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
if(isset($view->builds))
{
@@ -46,10 +47,11 @@ class blockZenTest extends baseTest
*/
public function printCaseBlockTest(object $block)
{
$this->invokeArgs('printCaseBlock', array($block));
$this->invokeArgs('printCaseBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
if(isset($view->cases))
{
@@ -75,11 +77,13 @@ class blockZenTest extends baseTest
public function printDocDynamicBlockTest()
{
ob_start();
$this->invokeArgs('printDocDynamicBlock', array());
$this->invokeArgs('printDocDynamicBlock');
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
if(isset($view->actions))
{
@@ -114,11 +118,13 @@ class blockZenTest extends baseTest
public function printDocMyCollectionBlockTest()
{
ob_start();
$this->invokeArgs('printDocMyCollectionBlock', array());
$this->invokeArgs('printDocMyCollectionBlock');
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
if(isset($view->docList))
{
@@ -144,11 +150,13 @@ class blockZenTest extends baseTest
public function printDocCollectListBlockTest()
{
ob_start();
$this->invokeArgs('printDocCollectListBlock', array());
$this->invokeArgs('printDocCollectListBlock');
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
if(isset($view->docList))
{
@@ -174,11 +182,13 @@ class blockZenTest extends baseTest
public function printDocMyCreatedBlockTest()
{
ob_start();
$this->invokeArgs('printDocMyCreatedBlock', array());
$this->invokeArgs('printDocMyCreatedBlock');
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
if(isset($view->docList))
{
@@ -204,11 +214,13 @@ class blockZenTest extends baseTest
public function printDocRecentUpdateBlockTest()
{
ob_start();
$this->invokeArgs('printDocRecentUpdateBlock', array());
$this->invokeArgs('printDocRecentUpdateBlock');
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
if(isset($view->docList))
{
@@ -234,11 +246,13 @@ class blockZenTest extends baseTest
public function printDocViewListBlockTest()
{
ob_start();
$this->invokeArgs('printDocViewListBlock', array());
$this->invokeArgs('printDocViewListBlock');
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
if(isset($view->docList))
{
@@ -264,10 +278,11 @@ class blockZenTest extends baseTest
*/
public function printExecutionListBlockTest(object $block)
{
$this->invokeArgs('printExecutionListBlock', array($block));
$this->invokeArgs('printExecutionListBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
if(isset($view->executions))
{
@@ -294,16 +309,17 @@ class blockZenTest extends baseTest
*/
public function printExecutionStatisticBlockTest(object $block, array $params = array())
{
$this->invokeArgs('printExecutionStatisticBlock', array($block, $params));
$this->invokeArgs('printExecutionStatisticBlock', [$block, $params]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->executionsCount = isset($view->executions) ? count($view->executions) : 0;
$result->projectsCount = isset($view->projects) ? count($view->projects) : 0;
$result->hasChartData = isset($view->chartData) ? 1 : 0;
$result->executionsCount = isset($view->executions) ? count($view->executions) : 0;
$result->projectsCount = isset($view->projects) ? count($view->projects) : 0;
$result->hasChartData = isset($view->chartData) ? 1 : 0;
$result->labelsCount = isset($view->chartData['labels']) ? count($view->chartData['labels']) : 0;
$result->currentProjectID = isset($view->currentProjectID) ? $view->currentProjectID : 0;
$result->currentProjectID = isset($view->currentProjectID) ? $view->currentProjectID : 0;
return $result;
}
@@ -316,20 +332,21 @@ class blockZenTest extends baseTest
*/
public function printGuideBlockTest(object $block)
{
$this->invokeArgs('printGuideBlock', array($block));
$this->invokeArgs('printGuideBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->blockID = isset($view->blockID) ? $view->blockID : 0;
$result->programsCount = isset($view->programs) ? count($view->programs) : 0;
$result->programID = isset($view->programID) ? $view->programID : 0;
$result->URSRListCount = isset($view->URSRList) ? count($view->URSRList) : 0;
$result->URSR = isset($view->URSR) ? $view->URSR : '';
$result->programLink = isset($view->programLink) ? $view->programLink : '';
$result->productLink = isset($view->productLink) ? $view->productLink : '';
$result->projectLink = isset($view->projectLink) ? $view->projectLink : '';
$result->executionLink = isset($view->executionLink) ? $view->executionLink : '';
$result->blockID = isset($view->blockID) ? $view->blockID : 0;
$result->programsCount = isset($view->programs) ? count($view->programs) : 0;
$result->programID = isset($view->programID) ? $view->programID : 0;
$result->URSRListCount = isset($view->URSRList) ? count($view->URSRList) : 0;
$result->URSR = isset($view->URSR) ? $view->URSR : '';
$result->programLink = isset($view->programLink) ? $view->programLink : '';
$result->productLink = isset($view->productLink) ? $view->productLink : '';
$result->projectLink = isset($view->projectLink) ? $view->projectLink : '';
$result->executionLink = isset($view->executionLink) ? $view->executionLink : '';
return $result;
}
@@ -341,17 +358,18 @@ class blockZenTest extends baseTest
*/
public function printMonthlyProgressBlockTest()
{
$this->invokeArgs('printMonthlyProgressBlock', array());
$this->invokeArgs('printMonthlyProgressBlock');
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->doneStoryEstimateCount = isset($view->doneStoryEstimate) ? count($view->doneStoryEstimate) : 0;
$result->doneStoryCountCount = isset($view->doneStoryCount) ? count($view->doneStoryCount) : 0;
$result->createStoryCountCount = isset($view->createStoryCount) ? count($view->createStoryCount) : 0;
$result->fixedBugCountCount = isset($view->fixedBugCount) ? count($view->fixedBugCount) : 0;
$result->createBugCountCount = isset($view->createBugCount) ? count($view->createBugCount) : 0;
$result->totalDataArrays = $result->doneStoryEstimateCount + $result->doneStoryCountCount + $result->createStoryCountCount + $result->fixedBugCountCount + $result->createBugCountCount;
$result->doneStoryCountCount = isset($view->doneStoryCount) ? count($view->doneStoryCount) : 0;
$result->createStoryCountCount = isset($view->createStoryCount) ? count($view->createStoryCount) : 0;
$result->fixedBugCountCount = isset($view->fixedBugCount) ? count($view->fixedBugCount) : 0;
$result->createBugCountCount = isset($view->createBugCount) ? count($view->createBugCount) : 0;
$result->totalDataArrays = $result->doneStoryEstimateCount + $result->doneStoryCountCount + $result->createStoryCountCount + $result->fixedBugCountCount + $result->createBugCountCount;
return $result;
}
@@ -365,14 +383,15 @@ class blockZenTest extends baseTest
public function printPlanBlockTest(object $block)
{
ob_start();
$this->invokeArgs('printPlanBlock', array($block));
$this->invokeArgs('printPlanBlock', [$block]);
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->productsCount = isset($view->products) ? count($view->products) : 0;
$result->plansCount = isset($view->plans) ? count($view->plans) : 0;
$result->plansCount = isset($view->plans) ? count($view->plans) : 0;
if(isset($view->plans))
{
foreach($view->plans as $index => $plan)
@@ -394,14 +413,16 @@ class blockZenTest extends baseTest
public function printProductDocBlockTest(object $block, array $params = array())
{
ob_start();
$this->invokeArgs('printProductDocBlock', array($block, $params));
$this->invokeArgs('printProductDocBlock', [$block, $params]);
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->type = isset($view->type) ? $view->type : '';
$result->usersCount = isset($view->users) ? count($view->users) : 0;
$result->type = isset($view->type) ? $view->type : '';
$result->usersCount = isset($view->users) ? count($view->users) : 0;
$result->productsCount = isset($view->products) ? count($view->products) : 0;
$result->docGroupCount = isset($view->docGroup) ? count($view->docGroup) : 0;
if(isset($view->products))
@@ -424,15 +445,17 @@ class blockZenTest extends baseTest
public function printProductListBlockTest(object $block)
{
ob_start();
$this->invokeArgs('printProductListBlock', array($block));
$this->invokeArgs('printProductListBlock', [$block]);
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->productStatsCount = isset($view->productStats) ? count($view->productStats) : 0;
$result->usersCount = isset($view->users) ? count($view->users) : 0;
$result->avatarListCount = isset($view->avatarList) ? count($view->avatarList) : 0;
$result->usersCount = isset($view->users) ? count($view->users) : 0;
$result->avatarListCount = isset($view->avatarList) ? count($view->avatarList) : 0;
if(isset($view->productStats))
{
foreach($view->productStats as $index => $product)
@@ -452,10 +475,11 @@ class blockZenTest extends baseTest
*/
public function printProductStatisticBlockTest(object $block)
{
$this->invokeArgs('printProductStatisticBlock', array($block));
$this->invokeArgs('printProductStatisticBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->productsCount = isset($view->products) ? count($view->products) : 0;
if(isset($view->products))
@@ -477,10 +501,11 @@ class blockZenTest extends baseTest
*/
public function printProjectOverviewBlockTest(object $block)
{
$this->invokeArgs('printProjectOverviewBlock', array($block));
$this->invokeArgs('printProjectOverviewBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->groupsCount = isset($view->groups) ? count($view->groups) : 0;
@@ -500,7 +525,7 @@ class blockZenTest extends baseTest
if(isset($group->type) && $group->type == 'barChart' && isset($group->bars))
{
$result->$groupKey->barsCount = count($group->bars);
$result->$groupKey->title = isset($group->title) ? $group->title : '';
$result->$groupKey->title = isset($group->title) ? $group->title : '';
}
}
}
@@ -517,14 +542,16 @@ class blockZenTest extends baseTest
public function printProjectStatisticBlockTest(object $block)
{
ob_start();
$this->invokeArgs('printProjectStatisticBlock', array($block));
$this->invokeArgs('printProjectStatisticBlock', [$block]);
ob_get_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->projectCount = isset($view->projects) ? count($view->projects) : 0;
$result->userCount = isset($view->users) ? count($view->users) : 0;
$result->userCount = isset($view->users) ? count($view->users) : 0;
if(isset($view->projects))
{
@@ -532,8 +559,8 @@ class blockZenTest extends baseTest
{
$projectKey = 'project' . $index;
$result->$projectKey = new stdClass();
$result->$projectKey->id = isset($project->id) ? $project->id : 0;
$result->$projectKey->name = isset($project->name) ? $project->name : '';
$result->$projectKey->id = isset($project->id) ? $project->id : 0;
$result->$projectKey->name = isset($project->name) ? $project->name : '';
$result->$projectKey->status = isset($project->status) ? $project->status : '';
}
}
@@ -549,24 +576,26 @@ class blockZenTest extends baseTest
public function printScrumOverviewBlockTest()
{
ob_start();
$this->invokeArgs('printScrumOverviewBlock', array());
$this->invokeArgs('printScrumOverviewBlock');
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->projectID = isset($view->projectID) ? $view->projectID : 0;
$result->hasProject = isset($view->project) ? 1 : 0;
$result->projectID = isset($view->projectID) ? $view->projectID : 0;
$result->hasProject = isset($view->project) ? 1 : 0;
if(isset($view->project))
{
$project = $view->project;
$result->projectName = isset($project->name) ? $project->name : '';
$result->projectModel = isset($project->model) ? $project->model : '';
$result->executionsCount = isset($project->executions) ? count($project->executions) : 0;
$result->storyPoints = isset($project->storyPoints) ? $project->storyPoints : 0;
$result->tasks = isset($project->tasks) ? $project->tasks : 0;
$result->bugs = isset($project->bugs) ? $project->bugs : 0;
$result->projectName = isset($project->name) ? $project->name : '';
$result->projectModel = isset($project->model) ? $project->model : '';
$result->executionsCount = isset($project->executions) ? count($project->executions) : 0;
$result->storyPoints = isset($project->storyPoints) ? $project->storyPoints : 0;
$result->tasks = isset($project->tasks) ? $project->tasks : 0;
$result->bugs = isset($project->bugs) ? $project->bugs : 0;
}
return $result;
@@ -581,14 +610,15 @@ class blockZenTest extends baseTest
*/
public function printScrumProductBlockTest(object $block)
{
$this->invokeArgs('printScrumProductBlock', array($block));
$this->invokeArgs('printScrumProductBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->productsCount = isset($view->products) ? count($view->products) : 0;
$result->storiesCount = isset($view->stories) ? count($view->stories) : 0;
$result->bugsCount = isset($view->bugs) ? count($view->bugs) : 0;
$result->storiesCount = isset($view->stories) ? count($view->stories) : 0;
$result->bugsCount = isset($view->bugs) ? count($view->bugs) : 0;
$result->releasesCount = isset($view->releases) ? count($view->releases) : 0;
if(isset($view->products))
@@ -596,10 +626,11 @@ class blockZenTest extends baseTest
foreach($view->products as $productID => $productName)
{
$productKey = 'product' . $productID;
$result->$productKey = new stdClass();
$result->$productKey->name = $productName;
$result->$productKey->storyTotal = isset($view->stories[$productID]) ? $view->stories[$productID] : 0;
$result->$productKey->bugTotal = isset($view->bugs[$productID]) ? $view->bugs[$productID] : 0;
$result->$productKey->name = $productName;
$result->$productKey->storyTotal = isset($view->stories[$productID]) ? $view->stories[$productID] : 0;
$result->$productKey->bugTotal = isset($view->bugs[$productID]) ? $view->bugs[$productID] : 0;
$result->$productKey->releaseTotal = isset($view->releases[$productID]) ? $view->releases[$productID] : 0;
}
}
@@ -617,17 +648,19 @@ class blockZenTest extends baseTest
public function printScrumRoadMapBlockTest(int $productID = 0, int $roadMapID = 0)
{
ob_start();
$this->invokeArgs('printScrumRoadMapBlock', array($productID, $roadMapID));
$this->invokeArgs('printScrumRoadMapBlock', [$productID, $roadMapID]);
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->productsCount = isset($view->products) ? count($view->products) : 0;
$result->roadmapsCount = isset($view->roadmaps) ? count($view->roadmaps) : 0;
$result->productID = isset($view->productID) ? $view->productID : 0;
$result->roadMapID = isset($view->roadMapID) ? $view->roadMapID : 0;
$result->sync = isset($view->sync) ? $view->sync : 0;
$result->productsCount = isset($view->products) ? count($view->products) : 0;
$result->roadmapsCount = isset($view->roadmaps) ? count($view->roadmaps) : 0;
$result->productID = isset($view->productID) ? $view->productID : 0;
$result->roadMapID = isset($view->roadMapID) ? $view->roadMapID : 0;
$result->sync = isset($view->sync) ? $view->sync : 0;
if(isset($view->roadmaps))
{
@@ -652,14 +685,15 @@ class blockZenTest extends baseTest
*/
public function printScrumTestBlockTest(object $block)
{
$this->invokeArgs('printScrumTestBlock', array($block));
$this->invokeArgs('printScrumTestBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->projectID = (isset($view->project) && $view->project) ? $view->project->id : 0;
$result->projectID = (isset($view->project) && $view->project) ? $view->project->id : 0;
$result->projectName = (isset($view->project) && $view->project) ? $view->project->name : '';
$result->type = isset($block->params->type) ? $block->params->type : '';
$result->type = isset($block->params->type) ? $block->params->type : '';
if(isset($view->testtasks))
{
$result->count = count($view->testtasks);
@@ -684,19 +718,20 @@ class blockZenTest extends baseTest
*/
public function printSingleBugStatisticBlockTest(object $block)
{
$this->invokeArgs('printSingleBugStatisticBlock', array($block));
$this->invokeArgs('printSingleBugStatisticBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->productID = isset($view->productID) ? $view->productID : 0;
$result->totalBugs = isset($view->totalBugs) ? $view->totalBugs : 0;
$result->closedBugs = isset($view->closedBugs) ? $view->closedBugs : 0;
$result->unresovledBugs = isset($view->unresovledBugs) ? $view->unresovledBugs : 0;
$result->resolvedRate = isset($view->resolvedRate) ? $view->resolvedRate : 0;
$result->monthsCount = isset($view->months) ? count($view->months) : 0;
$result->activateBugsCount = isset($view->activateBugs) ? count($view->activateBugs) : 0;
$result->closeBugsCount = isset($view->closeBugs) ? count($view->closeBugs) : 0;
$result->productID = isset($view->productID) ? $view->productID : 0;
$result->totalBugs = isset($view->totalBugs) ? $view->totalBugs : 0;
$result->closedBugs = isset($view->closedBugs) ? $view->closedBugs : 0;
$result->unresovledBugs = isset($view->unresovledBugs) ? $view->unresovledBugs : 0;
$result->resolvedRate = isset($view->resolvedRate) ? $view->resolvedRate : 0;
$result->monthsCount = isset($view->months) ? count($view->months) : 0;
$result->activateBugsCount = isset($view->activateBugs) ? count($view->activateBugs) : 0;
$result->closeBugsCount = isset($view->closeBugs) ? count($view->closeBugs) : 0;
return $result;
}
@@ -709,15 +744,17 @@ class blockZenTest extends baseTest
public function printSingleDynamicBlockTest()
{
ob_start();
$this->invokeArgs('printSingleDynamicBlock', array());
$this->invokeArgs('printSingleDynamicBlock');
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->productID = isset($view->productID) ? $view->productID : 0;
$result->actionsCount = isset($view->actions) ? count($view->actions) : 0;
$result->usersCount = isset($view->users) ? count($view->users) : 0;
$result->productID = isset($view->productID) ? $view->productID : 0;
$result->actionsCount = isset($view->actions) ? count($view->actions) : 0;
$result->usersCount = isset($view->users) ? count($view->users) : 0;
if(isset($view->actions))
{
@@ -738,28 +775,28 @@ class blockZenTest extends baseTest
*/
public function printSingleMonthlyProgressBlockTest($productID = 1)
{
global $tester;
// 设置session中的产品ID
$tester->session->product = $productID;
$this->instance->session->product = $productID;
// 调用方法
ob_start();
$this->invokeArgs('printSingleMonthlyProgressBlock', array());
$this->invokeArgs('printSingleMonthlyProgressBlock');
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->productID = $productID;
// 获取view中设置的数据
$result->doneStoryEstimate = isset($view->doneStoryEstimate) ? $view->doneStoryEstimate : array();
$result->doneStoryCount = isset($view->doneStoryCount) ? $view->doneStoryCount : array();
$result->createStoryCount = isset($view->createStoryCount) ? $view->createStoryCount : array();
$result->fixedBugCount = isset($view->fixedBugCount) ? $view->fixedBugCount : array();
$result->createBugCount = isset($view->createBugCount) ? $view->createBugCount : array();
$result->releaseCount = isset($view->releaseCount) ? $view->releaseCount : array();
$result->doneStoryEstimate = isset($view->doneStoryEstimate) ? $view->doneStoryEstimate : [];
$result->doneStoryCount = isset($view->doneStoryCount) ? $view->doneStoryCount : [];
$result->createStoryCount = isset($view->createStoryCount) ? $view->createStoryCount : [];
$result->fixedBugCount = isset($view->fixedBugCount) ? $view->fixedBugCount : [];
$result->createBugCount = isset($view->createBugCount) ? $view->createBugCount : [];
$result->releaseCount = isset($view->releaseCount) ? $view->releaseCount : [];
// 统计数据
$result->doneStoryEstimateCount = count($result->doneStoryEstimate);
@@ -782,20 +819,20 @@ class blockZenTest extends baseTest
*/
public function printSinglePlanBlockTest(object $block, int $productID = 1)
{
global $tester;
// 设置session中的产品ID
$tester->session->product = $productID;
$this->instance->session->product = $productID;
// 调用方法
ob_start();
$this->invokeArgs('printSinglePlanBlock', array($block));
$this->invokeArgs('printSinglePlanBlock', [$block]);
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->plansCount = isset($view->plans) ? count($view->plans) : 0;
$result->plansCount = isset($view->plans) ? count($view->plans) : 0;
$result->productsCount = isset($view->products) ? count($view->products) : 0;
if(isset($view->plans))
@@ -824,21 +861,21 @@ class blockZenTest extends baseTest
*/
public function printSingleReleaseBlockTest(object $block, int $productID = 1)
{
global $tester;
// 设置session中的产品ID
$tester->session->product = $productID;
$this->instance->session->product = $productID;
// 调用方法
ob_start();
$this->invokeArgs('printSingleReleaseBlock', array($block));
$this->invokeArgs('printSingleReleaseBlock', [$block]);
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->releasesCount = isset($view->releases) ? count($view->releases) : 0;
$result->buildsCount = isset($view->builds) ? count($view->builds) : 0;
$result->buildsCount = isset($view->builds) ? count($view->builds) : 0;
if(isset($view->releases))
{
@@ -865,21 +902,22 @@ class blockZenTest extends baseTest
*/
public function printSingleStatisticBlockTest(object $block)
{
$this->invokeArgs('printSingleStatisticBlock', array($block));
$this->invokeArgs('printSingleStatisticBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->productID = isset($view->product) && isset($view->product->id) ? $view->product->id : 0;
$result->productName = isset($view->product) && isset($view->product->name) ? $view->product->name : '';
$result->productID = isset($view->product) && isset($view->product->id) ? $view->product->id : 0;
$result->productName = isset($view->product) && isset($view->product->name) ? $view->product->name : '';
$result->storyDeliveryRate = isset($view->product) && isset($view->product->storyDeliveryRate) ? $view->product->storyDeliveryRate : 0;
$result->totalStories = isset($view->product) && isset($view->product->totalStories) ? $view->product->totalStories : 0;
$result->closedStories = isset($view->product) && isset($view->product->closedStories) ? $view->product->closedStories : 0;
$result->unclosedStories = isset($view->product) && isset($view->product->unclosedStories) ? $view->product->unclosedStories : 0;
$result->hasNewPlan = isset($view->product) && isset($view->product->newPlan) && $view->product->newPlan ? 1 : 0;
$result->hasNewExecution = isset($view->product) && isset($view->product->newExecution) && $view->product->newExecution ? 1 : 0;
$result->hasNewRelease = isset($view->product) && isset($view->product->newRelease) && $view->product->newRelease ? 1 : 0;
$result->monthFinishCount = isset($view->product) && isset($view->product->monthFinish) ? count($view->product->monthFinish) : 0;
$result->totalStories = isset($view->product) && isset($view->product->totalStories) ? $view->product->totalStories : 0;
$result->closedStories = isset($view->product) && isset($view->product->closedStories) ? $view->product->closedStories : 0;
$result->unclosedStories = isset($view->product) && isset($view->product->unclosedStories) ? $view->product->unclosedStories : 0;
$result->hasNewPlan = isset($view->product) && isset($view->product->newPlan) && $view->product->newPlan ? 1 : 0;
$result->hasNewExecution = isset($view->product) && isset($view->product->newExecution) && $view->product->newExecution ? 1 : 0;
$result->hasNewRelease = isset($view->product) && isset($view->product->newRelease) && $view->product->newRelease ? 1 : 0;
$result->monthFinishCount = isset($view->product) && isset($view->product->monthFinish) ? count($view->product->monthFinish) : 0;
$result->monthCreatedCount = isset($view->product) && isset($view->product->monthCreated) ? count($view->product->monthCreated) : 0;
return $result;
}
@@ -894,11 +932,13 @@ class blockZenTest extends baseTest
public function printStoryBlockTest(object $block)
{
ob_start();
$this->invokeArgs('printStoryBlock', array($block));
$this->invokeArgs('printStoryBlock', [$block]);
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->storiesCount = isset($view->stories) ? count($view->stories) : 0;
@@ -923,11 +963,13 @@ class blockZenTest extends baseTest
public function printSingleStoryBlockTest(object $block)
{
ob_start();
$this->invokeArgs('printSingleStoryBlock', array($block));
$this->invokeArgs('printSingleStoryBlock', [$block]);
ob_end_clean();
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->storiesCount = isset($view->stories) ? count($view->stories) : 0;
@@ -951,10 +993,11 @@ class blockZenTest extends baseTest
*/
public function printTaskBlockTest(object $block)
{
$this->invokeArgs('printTaskBlock', array($block));
$this->invokeArgs('printTaskBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->tasksCount = isset($view->tasks) ? count($view->tasks) : 0;
@@ -978,14 +1021,15 @@ class blockZenTest extends baseTest
*/
public function printTesttaskBlockTest(object $block)
{
$this->invokeArgs('printTesttaskBlock', array($block));
$this->invokeArgs('printTesttaskBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->testtasksCount = isset($view->testtasks) ? count($view->testtasks) : 0;
$result->type = $block->params->type ?? '';
$result->count = $block->params->count ?? 0;
$result->type = $block->params->type ?? '';
$result->count = $block->params->count ?? 0;
if(isset($view->testtasks))
{
@@ -1011,21 +1055,22 @@ class blockZenTest extends baseTest
*/
public function printTeamAchievementBlockTest()
{
$this->invokeArgs('printTeamAchievementBlock', array());
$this->invokeArgs('printTeamAchievementBlock');
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->finishedTasks = isset($view->finishedTasks) ? $view->finishedTasks : 0;
$result->yesterdayTasks = isset($view->yesterdayTasks) ? $view->yesterdayTasks : 0;
$result->createdStories = isset($view->createdStories) ? $view->createdStories : 0;
$result->finishedTasks = isset($view->finishedTasks) ? $view->finishedTasks : 0;
$result->yesterdayTasks = isset($view->yesterdayTasks) ? $view->yesterdayTasks : 0;
$result->createdStories = isset($view->createdStories) ? $view->createdStories : 0;
$result->yesterdayStories = isset($view->yesterdayStories) ? $view->yesterdayStories : 0;
$result->closedBugs = isset($view->closedBugs) ? $view->closedBugs : 0;
$result->yesterdayBugs = isset($view->yesterdayBugs) ? $view->yesterdayBugs : 0;
$result->runCases = isset($view->runCases) ? $view->runCases : 0;
$result->yesterdayCases = isset($view->yesterdayCases) ? $view->yesterdayCases : 0;
$result->consumedHours = isset($view->consumedHours) ? $view->consumedHours : 0;
$result->yesterdayHours = isset($view->yesterdayHours) ? $view->yesterdayHours : 0;
$result->closedBugs = isset($view->closedBugs) ? $view->closedBugs : 0;
$result->yesterdayBugs = isset($view->yesterdayBugs) ? $view->yesterdayBugs : 0;
$result->runCases = isset($view->runCases) ? $view->runCases : 0;
$result->yesterdayCases = isset($view->yesterdayCases) ? $view->yesterdayCases : 0;
$result->consumedHours = isset($view->consumedHours) ? $view->consumedHours : 0;
$result->yesterdayHours = isset($view->yesterdayHours) ? $view->yesterdayHours : 0;
return $result;
}
@@ -1038,23 +1083,24 @@ class blockZenTest extends baseTest
*/
public function printWaterfallEstimateBlockTest()
{
$this->invokeArgs('printWaterfallEstimateBlock', array());
$this->invokeArgs('printWaterfallEstimateBlock');
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->people = isset($view->people) ? $view->people : 0;
$result->members = isset($view->members) ? $view->members : 0;
$result->consumed = isset($view->consumed) ? $view->consumed : 0;
$result->people = isset($view->people) ? $view->people : 0;
$result->members = isset($view->members) ? $view->members : 0;
$result->consumed = isset($view->consumed) ? $view->consumed : 0;
$result->totalLeft = isset($view->totalLeft) ? $view->totalLeft : 0;
$result->hasBudget = isset($view->budget) ? 1 : 0;
$result->hasBudget = isset($view->budget) ? 1 : 0;
if(isset($view->budget))
{
$result->budgetScale = isset($view->budget->scale) ? $view->budget->scale : 0;
$result->budgetProductivity = isset($view->budget->productivity) ? $view->budget->productivity : 0;
$result->budgetDuration = isset($view->budget->duration) ? $view->budget->duration : 0;
$result->budgetUnitLaborCost = isset($view->budget->unitLaborCost) ? $view->budget->unitLaborCost : 0;
$result->budgetScale = isset($view->budget->scale) ? $view->budget->scale : 0;
$result->budgetProductivity = isset($view->budget->productivity) ? $view->budget->productivity : 0;
$result->budgetDuration = isset($view->budget->duration) ? $view->budget->duration : 0;
$result->budgetUnitLaborCost = isset($view->budget->unitLaborCost) ? $view->budget->unitLaborCost : 0;
$result->budgetTotalLaborCost = isset($view->budget->totalLaborCost) ? $view->budget->totalLaborCost : 0;
}
@@ -1069,16 +1115,17 @@ class blockZenTest extends baseTest
*/
public function printWaterfallGeneralReportBlockTest()
{
$this->invokeArgs('printWaterfallGeneralReportBlock', array());
$this->invokeArgs('printWaterfallGeneralReportBlock');
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->pv = isset($view->pv) ? $view->pv : 0;
$result->ev = isset($view->ev) ? $view->ev : 0;
$result->ac = isset($view->ac) ? $view->ac : 0;
$result->sv = isset($view->sv) ? $view->sv : 0;
$result->cv = isset($view->cv) ? $view->cv : 0;
$result->pv = isset($view->pv) ? $view->pv : 0;
$result->ev = isset($view->ev) ? $view->ev : 0;
$result->ac = isset($view->ac) ? $view->ac : 0;
$result->sv = isset($view->sv) ? $view->sv : 0;
$result->cv = isset($view->cv) ? $view->cv : 0;
$result->progress = isset($view->progress) ? $view->progress : 0;
return $result;
@@ -1093,21 +1140,21 @@ class blockZenTest extends baseTest
*/
public function printWaterfallProgressBlockTest(int $projectID = 1)
{
global $tester;
$tester->session->project = $projectID;
$this->instance->session->project = $projectID;
$this->invokeArgs('printWaterfallProgressBlock', array());
$this->invokeArgs('printWaterfallProgressBlock');
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
$result->hasCharts = isset($view->charts) ? 1 : 0;
$result->hasPV = isset($view->charts['pv']) ? 1 : 0;
$result->hasEV = isset($view->charts['ev']) ? 1 : 0;
$result->hasAC = isset($view->charts['ac']) ? 1 : 0;
$result->pvCount = isset($view->charts['pv']) ? count($view->charts['pv']) : 0;
$result->evCount = isset($view->charts['ev']) ? count($view->charts['ev']) : 0;
$result->acCount = isset($view->charts['ac']) ? count($view->charts['ac']) : 0;
$result->hasCharts = isset($view->charts) ? 1 : 0;
$result->hasPV = isset($view->charts['pv']) ? 1 : 0;
$result->hasEV = isset($view->charts['ev']) ? 1 : 0;
$result->hasAC = isset($view->charts['ac']) ? 1 : 0;
$result->pvCount = isset($view->charts['pv']) ? count($view->charts['pv']) : 0;
$result->evCount = isset($view->charts['ev']) ? count($view->charts['ev']) : 0;
$result->acCount = isset($view->charts['ac']) ? count($view->charts['ac']) : 0;
return $result;
}
@@ -1121,17 +1168,18 @@ class blockZenTest extends baseTest
*/
public function printWaterfallRiskBlockTest(object $block)
{
global $tester;
$tester->session->project = $block->params->projectID ?? 1;
$this->instance->session->project = $block->params->projectID ?? 1;
$this->invokeArgs('printWaterfallRiskBlock', array($block));
$this->invokeArgs('printWaterfallRiskBlock', [$block]);
if(dao::isError()) return dao::getError();
$view = $this->instance->view;
$view = $this->getProperty('view');
$result = new stdClass();
if(isset($view->risks))
{
$result->count = count($view->risks);
$index = 1;
foreach($view->risks as $risk)
{
@@ -1144,7 +1192,7 @@ class blockZenTest extends baseTest
$result->count = 0;
}
$result->hasUsers = isset($view->users) ? 1 : 0;
$result->hasUsers = isset($view->users) ? 1 : 0;
$result->usersCount = isset($view->users) ? count($view->users) : 0;
return $result;
@@ -1160,8 +1208,8 @@ class blockZenTest extends baseTest
*/
public function processBlockForRenderTest(array $blocks, int $projectID = 0)
{
$result = $this->invokeArgs('processBlockForRender', array($blocks, $projectID));
$result = $this->invokeArgs('processBlockForRender', [$blocks, $projectID]);
if(dao::isError()) return dao::getError();
return $result;
}
}
}
-70
View File
@@ -1,70 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 blockModel::checkAPI();
timeout=0
cid=15224
- 执行blockTest模块的checkAPITest方法,参数是'' @0
- 执行blockTest模块的checkAPITest方法,参数是'858640a724c2c981983935eb2bbc4ad8' @1
- 执行blockTest模块的checkAPITest方法,参数是'858640a724c2c98198wrong' @0
- 执行blockTest模块的checkAPITest方法,参数是'a' @0
- 执行blockTest模块的checkAPITest方法,参数是'123456789' @0
- 执行blockTest模块的checkAPITest方法,参数是'858640a724c2c981983935eb2bbc4ad8' @0
- 执行blockTest模块的checkAPITest方法,参数是'858640a724c2c981983935eb2bbc4ad8858640a724c2c981983935eb2bbc4ad8858640a724c2c981983935eb2bbc4ad8' @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
function initValidConfig()
{
$config = zenData('config');
$config->id->range('1');
$config->owner->range('system');
$config->module->range('sso');
$config->key->range('key');
$config->value->range('858640a724c2c981983935eb2bbc4ad8');
$config->gen(1);
}
function initEmptyConfig()
{
$config = zenData('config');
$config->gen(0);
}
su('admin');
$blockTest = new blockModelTest();
// 步骤1:测试空字符串哈希值情况
initValidConfig();
r($blockTest->checkAPITest('')) && p('') && e('0');
// 步骤2:测试正确哈希值匹配情况
initValidConfig();
r($blockTest->checkAPITest('858640a724c2c981983935eb2bbc4ad8')) && p('') && e('1');
// 步骤3:测试错误哈希值不匹配情况
initValidConfig();
r($blockTest->checkAPITest('858640a724c2c98198wrong')) && p('') && e('0');
// 步骤4:测试单个字符哈希值情况
initValidConfig();
r($blockTest->checkAPITest('a')) && p('') && e('0');
// 步骤5:测试数字字符哈希值情况
initValidConfig();
r($blockTest->checkAPITest('123456789')) && p('') && e('0');
// 步骤6:测试数据库配置不存在情况
initEmptyConfig();
r($blockTest->checkAPITest('858640a724c2c981983935eb2bbc4ad8')) && p('') && e('0');
// 步骤7:测试超长哈希值输入情况
initValidConfig();
r($blockTest->checkAPITest('858640a724c2c981983935eb2bbc4ad8858640a724c2c981983935eb2bbc4ad8858640a724c2c981983935eb2bbc4ad8')) && p('') && e('0');
+2 -2
View File
@@ -20,7 +20,7 @@ function initData()
$block->params->range('{"count":10}{3},{"type":"list"}{3},{}{4}');
$block->hidden->range('0{8},1{2}');
$block->vision->range('rnd{8},lite{2}');
$block->gen(10);
}
@@ -47,4 +47,4 @@ r($tester->block->updateLayout(array(1 => array('left' => 1, 'top' => 0)))) && p
r($tester->block->updateLayout(array(1 => array('left' => 2, 'top' => 3), 2 => array('left' => 0, 'top' => 6)))) && p() && e('1');
r($tester->block->updateLayout(array())) && p() && e('1');
r($tester->block->updateLayout(array(999 => array('left' => 1, 'top' => 0)))) && p() && e('1');
r($tester->block->updateLayout(array(1 => array('left' => 1, 'top' => 0, 'invalid' => 'test')))) && p() && e('1');
r($tester->block->updateLayout(array(1 => array('left' => 1, 'top' => 0, 'invalid' => 'test')))) && p() && e('1');
+17 -91
View File
@@ -20,9 +20,7 @@ class branchModelTest extends baseTest
public function getByIdTest($branchID, $productID = 0, $field = 'name')
{
$object = $this->instance->getById($branchID, $productID, $field);
if(dao::isError()) return dao::getError();
return $object;
}
@@ -39,12 +37,9 @@ class branchModelTest extends baseTest
public function getListTest($productID, $executionID = 0, $browseType = 'active', $withMainBranch = true)
{
$objects = $this->instance->getList($productID, $executionID, $browseType, 'order', null, $withMainBranch);
if(dao::isError()) return dao::getError();
$ids = '';
foreach($objects as $object) $ids .= ',' . $object->id;
return $ids;
return implode(',', array_column($objects, 'id'));
}
/**
@@ -60,12 +55,9 @@ class branchModelTest extends baseTest
public function getPairsTest($productID, $params = '', $executionID = 0, $mergedBranches = '')
{
$objects = $this->instance->getPairs($productID, $params, $executionID, $mergedBranches);
if(dao::isError()) return dao::getError();
$ids = '';
foreach($objects as $id => $object) $ids .= ',' . $id;
return $ids;
return implode(',', array_keys($objects));
}
/**
@@ -78,9 +70,7 @@ class branchModelTest extends baseTest
public function getAllPairsTest($params = '')
{
$objects = $this->instance->getAllPairs($params);
if(dao::isError()) return dao::getError();
return $objects;
}
@@ -94,9 +84,7 @@ class branchModelTest extends baseTest
public function getStatusListTest($productID)
{
$result = $this->instance->getStatusList($productID);
if(dao::isError()) return dao::getError();
return $result;
}
@@ -113,9 +101,7 @@ class branchModelTest extends baseTest
$objectID = $this->instance->create($productID, (object) $param);
if(dao::isError()) return dao::getError();
global $tester;
$object = $tester->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($objectID)->fetch();
return $object;
return $this->instance->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($objectID)->fetch();
}
/**
@@ -138,9 +124,7 @@ class branchModelTest extends baseTest
foreach($param as $key => $value) $newBranch->$key = $value;
$objects = $this->instance->update($branchID, $newBranch);
if(dao::isError()) return dao::getError();
return $objects;
}
@@ -153,10 +137,8 @@ class branchModelTest extends baseTest
*/
public function batchUpdateTest($param = array())
{
global $tester;
$productID = 6;
$branches = $tester->dao->select('*')->from(TABLE_BRANCH)->where('product')->eq($productID)->fetchAll('id');
$branches = $this->instance->dao->select('*')->from(TABLE_BRANCH)->where('product')->eq($productID)->fetchAll('id');
$newBranches = array();
foreach($branches as $branch)
@@ -181,7 +163,6 @@ class branchModelTest extends baseTest
}
$objects = $this->instance->batchUpdate($productID, $newBranches);
if(dao::isError()) return dao::getError();
return $objects;
}
@@ -196,12 +177,9 @@ class branchModelTest extends baseTest
public function closeTest($branchID)
{
$this->instance->close($branchID);
if(dao::isError()) return dao::getError();
global $tester;
$object = $tester->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch();
return $object;
return $this->instance->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch();
}
/**
@@ -214,12 +192,9 @@ class branchModelTest extends baseTest
public function activateTest($branchID)
{
$this->instance->activate($branchID);
if(dao::isError()) return dao::getError();
global $tester;
$object = $tester->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch();
return $object;
return $this->instance->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch();
}
/**
@@ -232,11 +207,9 @@ class branchModelTest extends baseTest
public function unlinkBranch4ProjectTest(array $productIDList): array|int
{
$this->instance->unlinkBranch4Project($productIDList);
if(dao::isError()) return dao::getError();
$objects = $this->instance->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('product')->in($productIDList)->andWhere('branch')->gt(0)->fetchAll();
return count($objects);
return $this->instance->dao->select('COUNT(1) AS count')->from(TABLE_PROJECTPRODUCT)->where('product')->in($productIDList)->andWhere('branch')->gt(0)->fetch('count');
}
/**
@@ -250,11 +223,9 @@ class branchModelTest extends baseTest
public function linkBranch4ProjectTest(int|array $productID): array|int
{
$this->instance->linkBranch4Project($productID);
if(dao::isError()) return dao::getError();
$objects = $this->instance->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('product')->in($productID)->andWhere('branch')->gt(0)->fetchAll();
return count($objects);
return $this->instance->dao->select('COUNT(1) AS count')->from(TABLE_PROJECTPRODUCT)->where('product')->in($productIDList)->andWhere('branch')->gt(0)->fetch('count');
}
/**
@@ -270,7 +241,6 @@ class branchModelTest extends baseTest
public function getByProductsTest(array $productIdList, string $params = '', array $appendBranch = array()): array|string
{
$objects = $this->instance->getByProducts($productIdList, $params, $appendBranch);
if(dao::isError()) return dao::getError();
$ids = '';
@@ -293,9 +263,7 @@ class branchModelTest extends baseTest
public function getProductTypeTest($branchID)
{
$type = $this->instance->getProductType($branchID);
if(dao::isError()) return dao::getError();
return $type;
}
@@ -310,12 +278,12 @@ class branchModelTest extends baseTest
public function sortTest(array $branchOrderList): array|string
{
$branchIdList = array_keys($branchOrderList);
$this->instance->sort($branchOrderList);
$this->instance->sort($branchOrderList);
if(dao::isError()) return dao::getError();
$objects = $this->instance->dao->select('*')->from(TABLE_BRANCH)->where('id')->in($branchIdList)->orderBy('order asc')->fetchAll('id');
return implode(',', array_keys($objects));
$idList = $this->instance->dao->select('id')->from(TABLE_BRANCH)->where('id')->in($branchIdList)->orderBy('`order`')->fetchPairs();
return implode(',', $idList);
}
/**
@@ -328,9 +296,7 @@ class branchModelTest extends baseTest
public function checkBranchDataTest($branchID)
{
$objects = $this->instance->checkBranchData($branchID);
if(dao::isError()) return dao::getError();
return $objects ? 1 : 2;
}
@@ -344,12 +310,9 @@ class branchModelTest extends baseTest
public function setDefaultTest(int $productID, int $branchID)
{
$this->instance->setDefault($productID, $branchID);
if(dao::isError()) return dao::getError();
$object = $this->instance->getById($branchID, $productID, '');
return $object;
return $this->instance->getById($branchID, $productID, '');
}
/**
@@ -363,7 +326,6 @@ class branchModelTest extends baseTest
public function getPairsByProjectProductTest($projectID, $productID)
{
$objects = $this->instance->getPairsByProjectProduct($projectID, $productID);
if(dao::isError()) return dao::getError();
$names = '';
@@ -383,9 +345,7 @@ class branchModelTest extends baseTest
public function showBranchTest($productID, $moduleID = 0, $executionID = 0)
{
$show = $this->instance->showBranch($productID, $moduleID = 0, $executionID = 0);
if(dao::isError()) return dao::getError();
return $show ? 1 : 2;
}
@@ -398,20 +358,12 @@ class branchModelTest extends baseTest
*/
public function changeBranchLanguageTest($productID)
{
global $tester;
global $app;
$app::$loadedLangs = array();
$app->loadLang('branch');
$result = $this->instance->changeBranchLanguage($productID);
if(dao::isError()) return dao::getError();
if($result === false) return '0';
$createLang = $tester->lang->branch->create;
return $createLang;
return $this->instance->lang->branch->create;
}
/**
@@ -432,28 +384,7 @@ class branchModelTest extends baseTest
if(dao::isError()) return dao::getError();
return $this->instance->dao->select('*')->from(TABLE_BRANCH)->where('deleted')->eq(0)->andWhere('product')->eq($productID)->fetchAll();
}
/**
* 合并分支后的其他数据处理。
* other data process after merge branch.
*
* @param int $productID
* @param string $mergedBranches
* @param object $data
* @access public
* @return array|int
*/
public function afterMergeTest(int $productID, string $mergedBranches, object $data): array|int
{
$targetBranch = $data->targetBranch;
$objectID = $this->instance->afterMerge($productID, $targetBranch, $mergedBranches, $data);
if(dao::isError()) return dao::getError();
$releases = $this->instance->dao->select('*')->from(TABLE_RELEASE)->where('deleted')->eq(0)->andWhere('branch')->in($data->mergedBranchIDList)->fetchAll();
return count($releases);
return $this->instance->dao->select('*')->from(TABLE_BRANCH)->where('deleted')->eq(0)->andWhere('product')->eq($productID)->fetchAll('', false);
}
/**
@@ -464,7 +395,7 @@ class branchModelTest extends baseTest
* @access public
* @return bool
*/
public function testIsClickable(int $branchID, string $status): bool
public function isClickableTest(int $branchID, string $status): bool
{
$branch = $this->instance->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch();
return $this->instance->isClickable($branch, $status);
@@ -481,18 +412,13 @@ class branchModelTest extends baseTest
*/
public function manageTest(int $productID, array $branchData = array(), array $newBranches = array())
{
global $tester;
// 清空之前的POST数据
$_POST = array();
// 设置POST数据以模拟实际提交
$_POST['branch'] = $branchData; // 确保branch总是存在,即使是空数组
$_POST = [];
$_POST['branch'] = $branchData; // 确保branch总是存在,即使是空数组
$_POST['newbranch'] = $newBranches; // 确保newbranch总是存在
// 调用被测方法
$result = $this->instance->manage($productID);
if(dao::isError()) return dao::getError();
// 如果返回false,表示DAO错误或其他问题
+2 -479
View File
@@ -8,433 +8,6 @@ class branchTaoTest extends baseTest
protected $moduleName = 'branch';
protected $className = 'tao';
/**
* Test get name by id.
*
* @param int $branchID
* @param int $productID
* @param string $field
* @access public
* @return object
*/
public function getByIdTest($branchID, $productID = 0, $field = 'name')
{
$object = $this->objectModel->getById($branchID, $productID, $field);
if(dao::isError()) return dao::getError();
return $object;
}
/**
* Test get branch list.
*
* @param int $productID
* @param int $executionID
* @param string $browseType
* @param bool $withMainBranch
* @access public
* @return string
*/
public function getListTest($productID, $executionID = 0, $browseType = 'active', $withMainBranch = true)
{
$objects = $this->objectModel->getList($productID, $executionID, $browseType, 'order', null, $withMainBranch);
if(dao::isError()) return dao::getError();
$ids = '';
foreach($objects as $object) $ids .= ',' . $object->id;
return $ids;
}
/**
* Test get pairs.
*
* @param int $productID
* @param string $params
* @param int $executionID
* @param string $mergedBranches
* @access public
* @return string
*/
public function getPairsTest($productID, $params = '', $executionID = 0, $mergedBranches = '')
{
$objects = $this->objectModel->getPairs($productID, $params, $executionID, $mergedBranches);
if(dao::isError()) return dao::getError();
$ids = '';
foreach($objects as $id => $object) $ids .= ',' . $id;
return $ids;
}
/**
* Test get all pairs.
*
* @param string $params
* @access public
* @return int
*/
public function getAllPairsTest($params = '')
{
$objects = $this->objectModel->getAllPairs($params);
if(dao::isError()) return dao::getError();
return $objects;
}
/**
* Test get status list.
*
* @param int $productID
* @access public
* @return array
*/
public function getStatusListTest($productID)
{
$result = $this->objectModel->getStatusList($productID);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test create a branch.
*
* @param int $productID
* @param array $param
* @access public
* @return object
*/
public function createTest($productID, $param = array())
{
$objectID = $this->objectModel->create($productID, (object) $param);
if(dao::isError()) return dao::getError();
global $tester;
$object = $tester->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($objectID)->fetch();
return $object;
}
/**
* Test update branch.
*
* @param array $param
* @access public
* @return array
*/
public function updateTest($param)
{
$branchID = 1;
$branch = $this->objectModel->getByID((string)$branchID, 0, '');
$newBranch = new stdclass();
$newBranch->name = $branch->name;
$newBranch->status = $branch->status;
$newBranch->desc = $branch->desc;
foreach($param as $key => $value) $newBranch->$key = $value;
$objects = $this->objectModel->update($branchID, $newBranch);
if(dao::isError()) return dao::getError();
return $objects;
}
/**
* Test batch update branch.
*
* @param array $param
* @access public
* @return object
*/
public function batchUpdateTest($param = array())
{
global $tester;
$productID = 6;
$branches = $tester->dao->select('*')->from(TABLE_BRANCH)->where('product')->eq($productID)->fetchAll('id');
$newBranches = array();
foreach($branches as $branch)
{
$newBranch = new stdclass();
$newBranch->branchID = $branch->id;
$newBranch->name = $branch->name;
$newBranch->desc = $branch->desc;
$newBranch->status = $branch->status;
foreach($param as $key => $setting)
{
foreach($setting as $id => $value)
{
if($id != $branch->id) continue;
$newBranch->$key = $value;
}
}
$newBranches[$branch->id] = $newBranch;
}
$objects = $this->objectModel->batchUpdate($productID, $newBranches);
if(dao::isError()) return dao::getError();
return $objects;
}
/**
* Test close a branch.
*
* @param int $branchID
* @access public
* @return object
*/
public function closeTest($branchID)
{
$this->objectModel->close($branchID);
if(dao::isError()) return dao::getError();
global $tester;
$object = $tester->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch();
return $object;
}
/**
* Test activate a branch.
*
* @param int $branchID
* @access public
* @return object
*/
public function activateTest($branchID)
{
$this->objectModel->activate($branchID);
if(dao::isError()) return dao::getError();
global $tester;
$object = $tester->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch();
return $object;
}
/**
* Test unlink branches for projects when product type is normal.
*
* @param array $productIDList
* @access public
* @return array|int
*/
public function unlinkBranch4ProjectTest(array $productIDList): array|int
{
$this->objectModel->unlinkBranch4Project($productIDList);
if(dao::isError()) return dao::getError();
$objects = $this->objectModel->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('product')->in($productIDList)->andWhere('branch')->gt(0)->fetchAll();
return count($objects);
}
/**
* 产品改为多分支类型时,处理分支关联项目。
* Test link branches for projects when product type is not normal.
*
* @param int|array $productID
* @access public
* @return int|array
*/
public function linkBranch4ProjectTest(int|array $productID): array|int
{
$this->objectModel->linkBranch4Project($productID);
if(dao::isError()) return dao::getError();
$objects = $this->objectModel->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('product')->in($productID)->andWhere('branch')->gt(0)->fetchAll();
return count($objects);
}
/**
* 按照产品分组获取分支数据。
* Test get branch group by products.
*
* @param array $productIdList
* @param string $params
* @param array $appendBranch
* @access public
* @return array|string
*/
public function getByProductsTest(array $productIdList, string $params = '', array $appendBranch = array()): array|string
{
$objects = $this->objectModel->getByProducts($productIdList, $params, $appendBranch);
if(dao::isError()) return dao::getError();
$ids = '';
foreach($objects as $productID => $branches)
{
$ids .= "$productID:";
foreach($branches as $branchID => $branchName) $ids .= "|$branchID";
$ids .= ';';
}
return $ids;
}
/**
* Test get product bype by branch.
*
* @param int $branchID
* @access public
* @return string
*/
public function getProductTypeTest($branchID)
{
$type = $this->objectModel->getProductType($branchID);
if(dao::isError()) return dao::getError();
return $type;
}
/**
* 分支排序。
* Test sort branch.
*
* @param array $branchOrderList
* @access public
* @return array|string
*/
public function sortTest(array $branchOrderList): array|string
{
$branchIdList = array_keys($branchOrderList);
$this->objectModel->sort($branchOrderList);
if(dao::isError()) return dao::getError();
$objects = $this->objectModel->dao->select('*')->from(TABLE_BRANCH)->where('id')->in($branchIdList)->orderBy('order asc')->fetchAll('id');
return implode(',', array_keys($objects));
}
/**
* Test check branch data.
*
* @param int $branchID
* @access public
* @return int
*/
public function checkBranchDataTest($branchID)
{
$objects = $this->objectModel->checkBranchData($branchID);
if(dao::isError()) return dao::getError();
return $objects ? 1 : 2;
}
/**
* Test check branch data.
*
* @param int $branchID
* @access public
* @return int
*/
public function setDefaultTest(int $productID, int $branchID)
{
$this->objectModel->setDefault($productID, $branchID);
if(dao::isError()) return dao::getError();
$object = $this->objectModel->getById($branchID, $productID, '');
return $object;
}
/**
* Test get branches of product which linked project.
*
* @param int $projectID
* @param int $productID
* @access public
* @return string
*/
public function getPairsByProjectProductTest($projectID, $productID)
{
$objects = $this->objectModel->getPairsByProjectProduct($projectID, $productID);
if(dao::isError()) return dao::getError();
$names = '';
foreach($objects as $id => $name) $names .= "$id:$name;";
return $names;
}
/**
* Test display of branch label.
*
* @param int $productID
* @param int $moduleID
* @param int $executionID
* @access public
* @return int
*/
public function showBranchTest($productID, $moduleID = 0, $executionID = 0)
{
$show = $this->objectModel->showBranch($productID, $moduleID = 0, $executionID = 0);
if(dao::isError()) return dao::getError();
return $show ? 1 : 2;
}
/**
* Test change branch language.
*
* @param int $productID
* @access public
* @return string
*/
public function changeBranchLanguageTest($productID)
{
global $tester;
global $app;
$app::$loadedLangs = array();
$app->loadLang('branch');
$result = $this->objectModel->changeBranchLanguage($productID);
if(dao::isError()) return dao::getError();
if($result === false) return '0';
$createLang = $tester->lang->branch->create;
return $createLang;
}
/**
* 将多个分支合并到一个分支。
* Test merge multiple branches into one branch.
*
* @param int $productID
* @param string $mergedBranches
* @param object $data
* @access public
* @return array
*/
public function mergeBranchTest(int $productID, string $mergedBranches, object $data): array
{
$data->status = 'active';
$data->createdDate = helper::today();
$objectID = $this->objectModel->mergeBranch($productID, $mergedBranches, $data);
if(dao::isError()) return dao::getError();
return $this->objectModel->dao->select('*')->from(TABLE_BRANCH)->where('deleted')->eq(0)->andWhere('product')->eq($productID)->fetchAll();
}
/**
* 合并分支后的其他数据处理。
* other data process after merge branch.
@@ -448,60 +21,10 @@ class branchTaoTest extends baseTest
public function afterMergeTest(int $productID, string $mergedBranches, object $data): array|int
{
$targetBranch = $data->targetBranch;
$objectID = $this->objectModel->afterMerge($productID, $targetBranch, $mergedBranches, $data);
$objectID = $this->instance->afterMerge($productID, $targetBranch, $mergedBranches, $data);
if(dao::isError()) return dao::getError();
$releases = $this->objectModel->dao->select('*')->from(TABLE_RELEASE)->where('deleted')->eq(0)->andWhere('branch')->in($data->mergedBranchIDList)->fetchAll();
return count($releases);
}
/**
* Test for judge a action is clickable.
*
* @param int $branchID
* @param string $status
* @access public
* @return bool
*/
public function testIsClickable(int $branchID, string $status): bool
{
$branch = $this->objectModel->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch();
return $this->objectModel->isClickable($branch, $status);
}
/**
* Test manage branch.
*
* @param int $productID
* @param array $branchData
* @param array $newBranches
* @access public
* @return mixed
*/
public function manageTest(int $productID, array $branchData = array(), array $newBranches = array())
{
global $tester;
// 清空之前的POST数据
$_POST = array();
// 设置POST数据以模拟实际提交
$_POST['branch'] = $branchData; // 确保branch总是存在,即使是空数组
$_POST['newbranch'] = $newBranches; // 确保newbranch总是存在
// 调用被测方法
$result = $this->objectModel->manage($productID);
if(dao::isError()) return dao::getError();
// 如果返回false,表示DAO错误或其他问题
if($result === false) return false;
// 如果结果包含JavaScript代码(空分支名错误),返回错误标识
if(!is_array($result)) return 'error';
// 返回新创建分支的数量
return count($result);
return $this->instance->dao->select('COUNT(1) AS count')->from(TABLE_RELEASE)->where('deleted')->eq(0)->andWhere('branch')->in($data->mergedBranchIDList)->fetch('count');
}
}
+9 -9
View File
@@ -13,15 +13,15 @@ timeout=0
cid=15332
*/
$branch = new branchTest('admin');
$branch = new branchModelTest('admin');
$idList = array(0, 2, 3, 30);
r($branch->testIsClickable($idList[0], 'activate')) && p() && e('0'); // 分支为空
r($branch->testIsClickable($idList[1], 'activate')) && p() && e('0'); // 分支2状态为为activate,action为activate
r($branch->testIsClickable($idList[2], 'activate')) && p() && e('1'); // 分支3状态为为close,action为activate
r($branch->testIsClickable($idList[3], 'activate')) && p() && e('0'); // 分支不存在
r($branch->isClickableTest($idList[0], 'activate')) && p() && e('0'); // 分支为空
r($branch->isClickableTest($idList[1], 'activate')) && p() && e('0'); // 分支2状态为为activate,action为activate
r($branch->isClickableTest($idList[2], 'activate')) && p() && e('1'); // 分支3状态为为close,action为activate
r($branch->isClickableTest($idList[3], 'activate')) && p() && e('0'); // 分支不存在
r($branch->testIsClickable($idList[0], 'close')) && p() && e('0'); // 分支为空
r($branch->testIsClickable($idList[1], 'close')) && p() && e('1'); // 分支2状态为为activate,action为close
r($branch->testIsClickable($idList[2], 'close')) && p() && e('0'); // 分支3状态为为close,action为close
r($branch->testIsClickable($idList[3], 'close')) && p() && e('0'); // 分支不存在
r($branch->isClickableTest($idList[0], 'close')) && p() && e('0'); // 分支为空
r($branch->isClickableTest($idList[1], 'close')) && p() && e('1'); // 分支2状态为为activate,action为close
r($branch->isClickableTest($idList[2], 'close')) && p() && e('0'); // 分支3状态为为close,action为close
r($branch->isClickableTest($idList[3], 'close')) && p() && e('0'); // 分支不存在
+1 -1
View File
@@ -718,7 +718,7 @@ class bugModel extends model
$staticData = array();
foreach($dateFields as $field)
{
$bugCount = $this->dao->select("count(id) as num, date_format($field, '%m/%d') as date")->from(TABLE_BUG)
$bugCount = $this->dao->select("COUNT(id) AS num, DATE_FORMAT($field, '%m/%d') AS date")->from(TABLE_BUG)
->where('product')->eq($productID)
->andWhere('deleted')->eq(0)
->andWhere($field)->between($startDate, $endDate . ' 23:50:59')
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+168 -2
View File
@@ -709,7 +709,7 @@ class bugZenTest extends baseTest
public function getTasksForCreateTest(object $bug)
{
$result = $this->invokeArgs('getTasksForCreate', [$bug]);
if(dao::isError()) return false;
if(dao::isError()) return dao::getError();
return $result;
}
@@ -723,7 +723,7 @@ class bugZenTest extends baseTest
public function initBugTest(array $fields = array()): object
{
$result = $this->invokeArgs('initBug', [$fields]);
if(dao::isError()) return (object)array();
if(dao::isError()) return dao::getError();
return $result;
}
@@ -1019,4 +1019,170 @@ class bugZenTest extends baseTest
if(dao::isError()) return false;
return $result;
}
/**
* Test setBrowseCookie method.
*
* @param object $product
* @param string $branch
* @param string $browseType
* @param int $param
* @param string $orderBy
* @access public
* @return bool
*/
public function setBrowseCookieTest(object $product, string $branch, string $browseType, int $param, string $orderBy): bool
{
$this->instance->app->rawModule = 'bug';
$this->instance->app->rawMethod = 'browse';
return $this->invokeArgs('setBrowseCookie', [$product, $branch, $browseType, $param, $orderBy]);
}
/**
* Test setCreateMenu method.
*
* @param int $productID
* @param string $branch
* @param array $output
* @access public
* @return bool
*/
public function setCreateMenuTest(int $productID, string $branch, array $output): bool
{
// 设置app属性
if(isset($output['executionID']))
{
$this->instance->app->tab = 'execution';
$this->instance->session->set('execution', $output['executionID']);
}
elseif(isset($output['projectID']))
{
$this->instance->app->tab = 'project';
}
else
{
$this->instance->app->tab = 'qa';
}
$result = $this->invokeArgs('setCreateMenu', [$productID, $branch, $output]);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test setEditMenu method.
*
* @param int $bugID
* @param string $tab
* @access public
* @return int
*/
public function setEditMenuTest(int $bugID, string $tab): int
{
// 获取bug对象
$bug = $this->instance->getById($bugID);
if(!$bug) return 0;
// 设置app tab
$this->instance->app->tab = $tab;
$result = $this->invokeArgs('setEditMenu', [$bug]);
if(dao::isError()) return 0;
return $result ? 1 : 0;
}
/**
* Test setViewMenu method.
*
* @param object $bug
* @param string $tab
* @access public
* @return bool
*/
public function setViewMenuTest(object $bug, string $tab): bool
{
// 设置app tab
$this->instance->app->tab = $tab;
$result = $this->invokeArgs('setViewMenu', [$bug]);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test getBranchesForCreate method.
*
* @param object $bug
* @access public
* @return object|array|string
*/
public function getBranchesForCreateTest(object $bug): object|array|string
{
$result = $this->invokeArgs('getBranchesForCreate', [$bug]);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test assignProjectRelatedVars method.
*
* @param array|null $bugs
* @param array|null $products
* @access public
* @return object|array|string
*/
public function assignProjectRelatedVarsTest($bugs = null, $products = null)
{
$result = $this->invokeArgs('assignProjectRelatedVars', [$bugs, $products]);
if(dao::isError()) return dao::getError();
return $this->getProperty('view');
}
/**
* Test responseAfterOperate method.
*
* @param int $bugID
* @param array $changes
* @param string $message
* @param bool $isInKanban
* @access public
* @return array
*/
public function responseAfterOperateTest(int $bugID, array $changes = array(), string $message = '', bool $isInKanban = false): array
{
$result = $this->invokeArgs('responseAfterOperate', [$bugID, $changes, $message, $isInKanban]);
if(dao::isError()) return array('error' => dao::getError());
return $result;
}
/**
* Test getToBeProcessedData method.
*
* @param object $bug
* @param object $oldBug
* @access public
* @return array
*/
public function getToBeProcessedDataTest(object $bug, object $oldBug): array
{
$result = $this->invokeArgs('getToBeProcessedData', [$bug, $oldBug]);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test processRepoIssueActions method.
*
* @param int $repoID
* @access public
* @return mixed
*/
public function processRepoIssueActionsTest($repoID = null)
{
$result = $this->invokeArgs('processRepoIssueActions', [$repoID]);
if(dao::isError()) return dao::getError();
return $result;
}
}
+2 -2
View File
@@ -20,8 +20,8 @@ cid=15346
*/
$bug=new bugModelTest();
$searchConfig = $bug->objectModel->buildSearchConfig(1, 'story');
$bugTest = new bugModelTest();
$searchConfig = $bugTest->instance->buildSearchConfig(1, 'story');
r($searchConfig['fields']) && p('title,module,steps') && e('Bug标题,所属模块,重现步骤'); // 测试字段名称
r($searchConfig['params']['assignedTo']) && p('operator,control') && e('=,select'); // 测试指派给字段
+13 -13
View File
@@ -37,17 +37,17 @@ su('admin');
$productIDList = array('1', '2', '3', '4','5', '6', '1000001', '45');
$branchIDList = array('9');
$bug=new bugModelTest();
$bug->objectModel->app->user->admin = true;
r($bug->getProductBugPairsTest($productIDList[0])) && p() && e('3:BUG3,2:BUG2,1:BUG1'); // 测试获取productID为1的bug
r($bug->getProductBugPairsTest($productIDList[1])) && p() && e('6:BUG6,5:BUG5,4:BUG4'); // 测试获取productID为2的bug
r($bug->getProductBugPairsTest($productIDList[2])) && p() && e('9:BUG9,8:bug8,7:缺陷!()(){}|+=^&*#测试bug名称到底可以有多长!#¥&*":.<>。?/();7'); // 测试获取productID为3的bug
r($bug->getProductBugPairsTest($productIDList[3])) && p() && e('12:BUG12,11:BUG11,10:BUG10'); // 测试获取productID为4的bug
r($bug->getProductBugPairsTest($productIDList[4])) && p() && e('15:缺陷!()(){}|+=^&*#测试bug名称到底可以有多长!#¥&*":.<>。?/();15,14:BUG14,13:BUG13'); // 测试获取productID为5的bug
r($bug->getProductBugPairsTest($productIDList[5])) && p() && e('18:BUG18,17:BUG17,16:bug16'); // 测试获取productID为6的bug
r($bug->getProductBugPairsTest($productIDList[6])) && p() && e('0'); // 测试获取不存在的product的bug
r($bug->getProductBugPairsTest($productIDList[7], 0)) && p() && e('133:BUG133'); // 测试获取productID为45,主干分支的bug
r($bug->getProductBugPairsTest($productIDList[7], $branchIDList[0])) && p() && e('134:BUG134'); // 测试获取productID为45,分支为9的bug
$bugTest = new bugModelTest();
$bugTest->instance->app->user->admin = true;
r($bugTest->getProductBugPairsTest($productIDList[0])) && p() && e('3:BUG3,2:BUG2,1:BUG1'); // 测试获取productID为1的bug
r($bugTest->getProductBugPairsTest($productIDList[1])) && p() && e('6:BUG6,5:BUG5,4:BUG4'); // 测试获取productID为2的bug
r($bugTest->getProductBugPairsTest($productIDList[2])) && p() && e('9:BUG9,8:bug8,7:缺陷!()(){}|+=^&*#测试bug名称到底可以有多长!#¥&*":.<>。?/();7'); // 测试获取productID为3的bug
r($bugTest->getProductBugPairsTest($productIDList[3])) && p() && e('12:BUG12,11:BUG11,10:BUG10'); // 测试获取productID为4的bug
r($bugTest->getProductBugPairsTest($productIDList[4])) && p() && e('15:缺陷!()(){}|+=^&*#测试bug名称到底可以有多长!#¥&*":.<>。?/();15,14:BUG14,13:BUG13'); // 测试获取productID为5的bug
r($bugTest->getProductBugPairsTest($productIDList[5])) && p() && e('18:BUG18,17:BUG17,16:bug16'); // 测试获取productID为6的bug
r($bugTest->getProductBugPairsTest($productIDList[6])) && p() && e('0'); // 测试获取不存在的product的bug
r($bugTest->getProductBugPairsTest($productIDList[7], 0)) && p() && e('133:BUG133'); // 测试获取productID为45,主干分支的bug
r($bugTest->getProductBugPairsTest($productIDList[7], $branchIDList[0])) && p() && e('134:BUG134'); // 测试获取productID为45,分支为9的bug
r(implode(',', $bug->objectModel->getProductBugPairs($productIDList[7], '', 'BUG1'))) && p() && e('134:BUG134,133:BUG133'); // 测试获取productID为45,标题匹配 BUG1 的bug
r(str_replace(array('@', '#'), array('64;', '35;'), implode(',', $bug->objectModel->getProductBugPairs($productIDList[7], '', 'BUG1', 3, 'all')))) && p() && e('134:BUG134,133:BUG133,产品35;164;1:BUG1'); // 测试获取所有标题匹配 BUG1 的3条bug,productID为45的bug排序前面。
r(implode(',', $bugTest->instance->getProductBugPairs($productIDList[7], '', 'BUG1'))) && p() && e('134:BUG134,133:BUG133'); // 测试获取productID为45,标题匹配 BUG1 的bug
r(str_replace(array('@', '#'), array('64;', '35;'), implode(',', $bugTest->instance->getProductBugPairs($productIDList[7], '', 'BUG1', 3, 'all')))) && p() && e('134:BUG134,133:BUG133,产品35;164;1:BUG1'); // 测试获取所有标题匹配 BUG1 的3条bug,productID为45的bug排序前面。
-2
View File
@@ -483,8 +483,6 @@ class bugZen extends bug
return true;
}
/**
* 为创建 bug 设置导航数据。
* Set menu for create bug page.
@@ -21,7 +21,7 @@ cid=15525
*/
$caselib = new caselibModelTest();
$searchConfig = $caselib->objectModel->buildSearchConfig(1);
$searchConfig = $caselib->instance->buildSearchConfig(1);
r($searchConfig['fields']) && p('title,story,type') && e('用例名称,关联需求,用例类型'); // 测试字段名称
r($searchConfig['params']['module']) && p('operator,control') && e('belong,select'); // 测试模块字段
-31
View File
@@ -1,31 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::allDBList();
timeout=0
cid=15598
- 执行cneTest模块的allDBListTest方法,参数是'success'
- 第zentaopaas-mysql条的db_type属性 @mysql
- 第zentaopaas-mysql条的release属性 @zentaopaas
- 执行cneTest模块的allDBListTest方法,参数是'empty' @0
- 执行cneTest模块的allDBListTest方法,参数是'error' @0
- 执行cneTest模块的allDBListTest方法,参数是'network_error' @0
- 执行cneTest模块的allDBListTest方法,参数是'invalid_config' @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$cneTest = new cneModelTest();
r($cneTest->allDBListTest('success')) && p('zentaopaas-mysql:db_type,release') && e('mysql,zentaopaas');
r($cneTest->allDBListTest('empty')) && p() && e('0');
r($cneTest->allDBListTest('error')) && p() && e('0');
r($cneTest->allDBListTest('network_error')) && p() && e('0');
r($cneTest->allDBListTest('invalid_config')) && p() && e('0');
-52
View File
@@ -1,52 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::appDBDetail();
timeout=0
cid=15601
- 步骤1:正常实例但无外部API连接 @0
- 步骤2:空实例对象 @0
- 步骤3:缺少k8name属性的实例 @0
- 步骤4:缺少spaceData属性的实例 @0
- 步骤5:空数据库名称参数 @0
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 创建测试实例
$cneTest = new cneModelTest();
// 3. 创建模拟实例对象用于测试
$instance1 = new stdClass();
$instance1->k8name = 'test-zentao-app';
$instance1->spaceData = new stdClass();
$instance1->spaceData->k8space = 'test-namespace';
$instance2 = null; // 空实例对象
$instance3 = new stdClass();
$instance3->spaceData = new stdClass();
$instance3->spaceData->k8space = 'test-namespace';
// 缺少k8name属性
$instance4 = new stdClass();
$instance4->k8name = 'test-app';
// 缺少spaceData属性
$instance5 = new stdClass();
$instance5->k8name = 'test-app';
$instance5->spaceData = new stdClass();
$instance5->spaceData->k8space = 'test-namespace';
// 4. 🔴 强制要求:必须包含至少5个测试步骤
r($cneTest->appDBDetailTest($instance1, 'zentao')) && p() && e('0'); // 步骤1:正常实例但无外部API连接
r($cneTest->appDBDetailTest($instance2, 'test_db')) && p() && e('0'); // 步骤2:空实例对象
r($cneTest->appDBDetailTest($instance3, 'zentao')) && p() && e('0'); // 步骤3:缺少k8name属性的实例
r($cneTest->appDBDetailTest($instance4, 'zentao')) && p() && e('0'); // 步骤4:缺少spaceData属性的实例
r($cneTest->appDBDetailTest($instance5, '')) && p() && e('0'); // 步骤5:空数据库名称参数
-55
View File
@@ -1,55 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::appDBList();
timeout=0
cid=15602
- 执行cneTest模块的appDBListByInstanceTest方法,参数是$instance1 @0
- 执行cneTest模块的appDBListByInstanceTest方法,参数是$instance2 @0
- 执行cneTest模块的appDBListByInstanceTest方法,参数是$instance3 @0
- 执行cneTest模块的appDBListByInstanceTest方法,参数是$instance4 @0
- 执行cneTest模块的appDBListByInstanceTest方法,参数是$instance5 @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$cneTest = new cneModelTest();
// 测试步骤1:创建有效实例对象
$instance1 = new stdClass();
$instance1->k8name = 'test-app1';
$instance1->spaceData = new stdClass();
$instance1->spaceData->k8space = 'test-namespace1';
// 测试步骤2:空实例对象
$instance2 = null;
// 测试步骤3:k8name为空的实例
$instance3 = new stdClass();
$instance3->k8name = '';
$instance3->spaceData = new stdClass();
$instance3->spaceData->k8space = 'test-namespace3';
// 测试步骤4:spaceData为空的实例
$instance4 = new stdClass();
$instance4->k8name = 'test-app4';
$instance4->spaceData = null;
// 测试步骤5:spaceData->k8space为空的实例
$instance5 = new stdClass();
$instance5->k8name = 'test-app5';
$instance5->spaceData = new stdClass();
$instance5->spaceData->k8space = '';
r($cneTest->appDBListByInstanceTest($instance1)) && p() && e('0');
r($cneTest->appDBListByInstanceTest($instance2)) && p() && e('0');
r($cneTest->appDBListByInstanceTest($instance3)) && p() && e('0');
r($cneTest->appDBListByInstanceTest($instance4)) && p() && e('0');
r($cneTest->appDBListByInstanceTest($instance5)) && p() && e('0');
-34
View File
@@ -1,34 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::backupDetail();
timeout=0
cid=15604
- 测试步骤1:空实例对象输入 @0
- 测试步骤2:缺少k8name属性的实例 @0
- 测试步骤3:无效备份计数输入 @0
- 测试步骤4:正常实例获取备份详情-数据库
- 第0条的db_type属性 @mysql
- 第0条的status属性 @completed
- 测试步骤5:正常实例获取备份详情-卷
- 第0条的volume属性 @data
- 第0条的status属性 @completed
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
$cneTest = new cneModelTest();
r($cneTest->backupDetailTest(new stdClass(), 0)) && p() && e('0'); // 测试步骤1:空实例对象输入
$instance = new stdClass(); $instance->spaceData = new stdClass(); $instance->spaceData->k8space = '';
r($cneTest->backupDetailTest($instance, 0)) && p() && e('0'); // 测试步骤2:缺少k8name属性的实例
$instance->k8name = 'zentaopaas'; $instance->spaceData->k8space = 'quickon-system';
r($cneTest->backupDetailTest($instance, 0)) && p() && e('0'); // 测试步骤3:无效备份计数输入
$backupDetail = $cneTest->backupDetailTest($instance, 1);
r($backupDetail->db) && p('0:db_type,status') && e('mysql,completed'); // 测试步骤4:正常实例获取备份详情-数据库
r($backupDetail->volume) && p('0:volume,status') && e('data,completed'); // 测试步骤5:正常实例获取备份详情-卷
@@ -1,68 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::batchQueryStatus();
timeout=0
cid=15605
- 步骤1:正常实例列表 @2
- 步骤2:空实例列表 @0
- 步骤3:单个实例 @1
- 步骤4:空channel实例第empty-channel-app条的status属性 @running
- 步骤5:默认模拟数据 @2
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 创建测试实例(变量名与模块名一致)
$cneTest = new cneModelTest();
// 3. 🔴 强制要求:必须包含至少5个测试步骤
// 步骤1:测试正常实例列表
$instance1 = new stdclass();
$instance1->k8name = 'test-app-1';
$instance1->chart = 'zentao';
$instance1->spaceData = new stdclass();
$instance1->spaceData->k8space = 'test-namespace-1';
$instance1->channel = 'stable';
$instance2 = new stdclass();
$instance2->k8name = 'test-app-2';
$instance2->chart = 'sonarqube';
$instance2->spaceData = new stdclass();
$instance2->spaceData->k8space = 'test-namespace-2';
$instance2->channel = 'beta';
r(count($cneTest->batchQueryStatusTest(array($instance1, $instance2)))) && p() && e('2'); // 步骤1:正常实例列表
// 步骤2:测试空实例列表
r(count($cneTest->batchQueryStatusTest(array()))) && p() && e('0'); // 步骤2:空实例列表
// 步骤3:测试单个实例
$singleInstance = new stdclass();
$singleInstance->k8name = 'single-app';
$singleInstance->chart = 'gitlab';
$singleInstance->spaceData = new stdclass();
$singleInstance->spaceData->k8space = 'single-namespace';
$singleInstance->channel = 'stable';
r(count($cneTest->batchQueryStatusTest(array($singleInstance)))) && p() && e('1'); // 步骤3:单个实例
// 步骤4:测试包含空channel的实例
$emptyChannelInstance = new stdclass();
$emptyChannelInstance->k8name = 'empty-channel-app';
$emptyChannelInstance->chart = 'zentao';
$emptyChannelInstance->spaceData = new stdclass();
$emptyChannelInstance->spaceData->k8space = 'empty-channel-namespace';
$emptyChannelInstance->channel = ''; // 空channel
r($cneTest->batchQueryStatusTest(array($emptyChannelInstance))) && p('empty-channel-app:status') && e('running'); // 步骤4:空channel实例
// 步骤5:测试默认场景(传入null参数,使用默认模拟数据)
r(count($cneTest->batchQueryStatusTest(null))) && p() && e('2'); // 步骤5:默认模拟数据
-27
View File
@@ -1,27 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::certInfo();
timeout=0
cid=15606
- 步骤1:空证书名称查询 @0
- 步骤2:无效证书名称查询 @0
- 步骤3:有效证书名称查询第sans条的0属性 @devops.corp.cc
- 步骤4:使用默认channel参数查询第sans条的0属性 @devops.corp.cc
- 步骤5:有效证书名称带自定义channel查询第sans条的0属性 @devops.corp.cc
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
$cneTest = new cneModelTest();
r($cneTest->certInfoTest('')) && p() && e('0'); // 步骤1:空证书名称查询
r($cneTest->certInfoTest('invalid-cert-name')) && p() && e('0'); // 步骤2:无效证书名称查询
r($cneTest->certInfoTest('tls-haogs-cn')) && p('sans:0') && e('devops.corp.cc'); // 步骤3:有效证书名称查询
r($cneTest->certInfoTest('tls-haogs-cn', '')) && p('sans:0') && e('devops.corp.cc'); // 步骤4:使用默认channel参数查询
r($cneTest->certInfoTest('tls-haogs-cn', 'stable')) && p('sans:0') && e('devops.corp.cc'); // 步骤5:有效证书名称带自定义channel查询
-31
View File
@@ -1,31 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::dbDetail();
timeout=0
cid=15609
- 步骤1:测试空参数边界值 @0
- 步骤2:测试部分参数为空的情况 @0
- 步骤3:测试错误数据库服务名的异常处理 @0
- 步骤4:测试空数据库服务名但有效命名空间 @0
- 步骤5:测试错误命名空间的异常处理 @0
- 步骤6:测试正确参数获取host属性属性host @zentaopaas-mysql.quickon-system.svc
- 步骤7:测试正确参数获取username属性属性username @root
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
$cneTest = new cneModelTest();
r($cneTest->dbDetailTest('', '')) && p() && e('0'); // 步骤1:测试空参数边界值
r($cneTest->dbDetailTest('mysql', '')) && p() && e('0'); // 步骤2:测试部分参数为空的情况
r($cneTest->dbDetailTest('mysql', 'quickon-system')) && p() && e('0'); // 步骤3:测试错误数据库服务名的异常处理
r($cneTest->dbDetailTest('', 'quickon-system')) && p() && e('0'); // 步骤4:测试空数据库服务名但有效命名空间
r($cneTest->dbDetailTest('zentaopaas-mysql', 'invalid-namespace')) && p() && e('0'); // 步骤5:测试错误命名空间的异常处理
r($cneTest->dbDetailTest('zentaopaas-mysql', 'quickon-system')) && p('host') && e('zentaopaas-mysql.quickon-system.svc'); // 步骤6:测试正确参数获取host属性
r($cneTest->dbDetailTest('zentaopaas-mysql', 'quickon-system')) && p('username') && e('root'); // 步骤7:测试正确参数获取username属性
-29
View File
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::getAppConfig();
timeout=0
cid=15611
- 执行cneTest模块的getAppConfigTest方法,参数是1 @0
- 执行cneTest模块的getAppConfigTest方法,参数是999 @0
- 执行cneTest模块的getAppConfigTest方法 @0
- 执行cneTest模块的getAppConfigTest方法,参数是-1 @0
- 执行cneTest模块的getAppConfigTest方法,参数是100 @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$cneTest = new cneModelTest();
r($cneTest->getAppConfigTest(1)) && p() && e('0');
r($cneTest->getAppConfigTest(999)) && p() && e('0');
r($cneTest->getAppConfigTest(0)) && p() && e('0');
r($cneTest->getAppConfigTest(-1)) && p() && e('0');
r($cneTest->getAppConfigTest(100)) && p() && e('0');
-31
View File
@@ -1,31 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel->getAppLogs();
timeout=0
cid=15612
- 获取CNE平台的日志 status @0
- 获取CNE平台的日志 status @0
- 获取CNE平台的日志 status @0
- 获取CNE平台的日志 status @0
- 获取CNE平台的日志 status @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
$cneModel = new cneModelTest();
r($cneModel->getAppLogsTest()) && p('status') && e('0');
r($cneModel->getAppLogsTest()) && p('status') && e('0');
r($cneModel->getAppLogsTest()) && p('status') && e('0');
r($cneModel->getAppLogsTest()) && p('status') && e('0');
r($cneModel->getAppLogsTest()) && p('status') && e('0');
-28
View File
@@ -1,28 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::getComponents();
timeout=0
cid=15616
- 执行cneTest模块的getComponentsTest方法 属性code @600
- 执行cneTest模块的getComponentsTest方法,参数是999 @0
- 执行cneTest模块的getComponentsTest方法 属性code @400
- 执行cneTest模块的getComponentsTest方法,参数是null @0
- 执行cneTest模块的getComponentsTest方法,参数是2 属性code @600
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 创建测试实例
$cneTest = new cneModelTest();
r($cneTest->getComponentsTest()) && p('code') && e('600');
r($cneTest->getComponentsTest(999)) && p() && e('0');
r($cneTest->getComponentsTest(0)) && p('code') && e('400');
r($cneTest->getComponentsTest(null)) && p() && e('0');
r($cneTest->getComponentsTest(2)) && p('code') && e('600');
@@ -1,52 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::getDefaultAccount();
timeout=0
cid=15617
- 步骤1:正常情况测试获取默认账号(空组件参数) @0
- 步骤2:使用mysql组件获取默认账号 @0
- 步骤3:使用redis组件获取默认账号 @0
- 步骤4:使用null实例参数 @0
- 步骤5:使用无效实例对象验证容错性 @0
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$cneTest = new cneModelTest();
// 创建模拟实例对象
$instance1 = new stdclass();
$instance1->id = 1;
$instance1->k8name = 'test-zentao-app-1';
$instance1->channel = 'stable';
$instance1->spaceData = new stdclass();
$instance1->spaceData->k8space = 'test-namespace';
$instance2 = new stdclass();
$instance2->id = 2;
$instance2->k8name = 'test-zentao-app-2';
$instance2->channel = 'stable';
$instance2->spaceData = new stdclass();
$instance2->spaceData->k8space = 'test-namespace';
$invalidInstance = new stdclass();
$invalidInstance->id = 999;
// 缺少必需的属性
// 5. 🔴 强制要求:必须包含至少5个测试步骤
r($cneTest->getDefaultAccountTest($instance1, '')) && p() && e('0'); // 步骤1:正常情况测试获取默认账号(空组件参数)
r($cneTest->getDefaultAccountTest($instance1, 'mysql')) && p() && e('0'); // 步骤2:使用mysql组件获取默认账号
r($cneTest->getDefaultAccountTest($instance2, 'redis')) && p() && e('0'); // 步骤3:使用redis组件获取默认账号
r($cneTest->getDefaultAccountTest(null)) && p() && e('0'); // 步骤4:使用null实例参数
r($cneTest->getDefaultAccountTest($invalidInstance, 'invalid-component')) && p() && e('0'); // 步骤5:使用无效实例对象验证容错性
-42
View File
@@ -1,42 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::getDomain();
timeout=0
cid=15619
- 步骤1:使用默认实例获取域名信息 @0
- 步骤2:使用默认实例和空组件名获取域名 @0
- 步骤3:使用默认实例和mysql组件获取域名 @0
- 步骤4:使用默认实例和web组件获取域名 @0
- 步骤5:使用无效实例对象获取域名 @0
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 创建测试实例(变量名与模块名一致)
$cneTest = new cneModelTest();
// 3. 准备测试数据:创建模拟实例对象
$validInstance = new stdclass();
$validInstance->id = 2;
$validInstance->k8name = 'test-zentao-app';
$validInstance->channel = 'stable';
$validInstance->spaceData = new stdclass();
$validInstance->spaceData->k8space = 'test-namespace';
$invalidInstance = new stdclass();
$invalidInstance->id = 999;
$invalidInstance->k8name = '';
// 4. 🔴 强制要求:必须包含至少5个测试步骤
r($cneTest->getDomainTest($validInstance, '')) && p() && e('0'); // 步骤1:使用默认实例获取域名信息
r($cneTest->getDomainTest($validInstance)) && p() && e('0'); // 步骤2:使用默认实例和空组件名获取域名
r($cneTest->getDomainTest($validInstance, 'mysql')) && p() && e('0'); // 步骤3:使用默认实例和mysql组件获取域名
r($cneTest->getDomainTest($validInstance, 'web')) && p() && e('0'); // 步骤4:使用默认实例和web组件获取域名
r($cneTest->getDomainTest($invalidInstance, '')) && p() && e('0'); // 步骤5:使用无效实例对象获取域名
-27
View File
@@ -1,27 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::getEvents();
timeout=0
cid=15620
- 执行cneTest模块的getEventsTest方法,参数是1, '' @200
- 执行cneTest模块的getEventsTest方法,参数是2, 'mysql' @200
- 执行cneTest模块的getEventsTest方法,参数是3, '' @0
- 执行cneTest模块的getEventsTest方法,参数是4, '' @600
- 执行cneTest模块的getEventsTest方法,参数是0, '' @600
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
$cneTest = new cneModelTest();
r($cneTest->getEventsTest(1, '')) && p() && e('200');
r($cneTest->getEventsTest(2, 'mysql')) && p() && e('200');
r($cneTest->getEventsTest(3, '')) && p() && e('0');
r($cneTest->getEventsTest(4, '')) && p() && e('600');
r($cneTest->getEventsTest(0, '')) && p() && e('600');
-37
View File
@@ -1,37 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::getPods();
timeout=0
cid=15621
- 步骤1:正常情况测试获取实例pods(实例ID=1) @0
- 步骤2:使用指定组件mysql获取pods @0
- 步骤3:测试无效实例ID的容错处理(实例ID=999) @0
- 步骤4:测试负数实例ID的边界情况(实例ID=-1) @0
- 步骤5:测试无效组件名的容错处理 @0
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. zendata数据准备(根据需要配置)
zenData('instance')->loadYaml('instance_getpods', false, 2)->gen(5);
zenData('space')->loadYaml('space_getpods', false, 2)->gen(3);
// 3. 用户登录(选择合适角色)
su('admin');
// 4. 创建测试实例(变量名与模块名一致)
$cneTest = new cneModelTest();
// 5. 🔴 强制要求:必须包含至少5个测试步骤
r($cneTest->getPodsTest(1)) && p() && e('0'); // 步骤1:正常情况测试获取实例pods(实例ID=1)
r($cneTest->getPodsTest(2, 'mysql')) && p() && e('0'); // 步骤2:使用指定组件mysql获取pods
r($cneTest->getPodsTest(999)) && p() && e('0'); // 步骤3:测试无效实例ID的容错处理(实例ID=999)
r($cneTest->getPodsTest(-1)) && p() && e('0'); // 步骤4:测试负数实例ID的边界情况(实例ID=-1)
r($cneTest->getPodsTest(3, 'invalid-component')) && p() && e('0'); // 步骤5:测试无效组件名的容错处理
@@ -1,68 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::getRestoreStatus();
timeout=0
cid=15622
- 步骤1:正常实例和有效备份名查询恢复状态
- 属性code @600
- 属性message @CNE服务器出错
- 步骤2:不存在的实例ID查询恢复状态
- 属性code @404
- 属性message @Instance not found
- 步骤3:无效实例ID(0)查询恢复状态
- 属性code @404
- 属性message @Instance not found
- 步骤4:空备份名查询恢复状态
- 属性code @400
- 属性message @Backup name cannot be empty
- 步骤5:负数实例ID查询恢复状态
- 属性code @404
- 属性message @Instance not found
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$cneTest = new cneModelTest();
// 创建模拟实例对象
$instance1 = new stdclass();
$instance1->id = 1;
$instance1->k8name = 'test-app-1';
$instance1->spaceData = new stdclass();
$instance1->spaceData->k8space = 'test-namespace';
$instance1->channel = 'stable';
$instance999 = new stdclass();
$instance999->id = 999;
$instance999->k8name = 'test-app-999';
$instance999->spaceData = new stdclass();
$instance999->spaceData->k8space = 'test-namespace';
$instance999->channel = 'stable';
$instance0 = new stdclass();
$instance0->id = 0;
$instance0->k8name = 'test-app-0';
$instance0->spaceData = new stdclass();
$instance0->spaceData->k8space = 'test-namespace';
$instance0->channel = 'stable';
$instanceNeg = new stdclass();
$instanceNeg->id = -1;
$instanceNeg->k8name = 'test-app-neg';
$instanceNeg->spaceData = new stdclass();
$instanceNeg->spaceData->k8space = 'test-namespace';
$instanceNeg->channel = 'stable';
r($cneTest->getRestoreStatusTest($instance1, 'backup-restore-001')) && p('code,message') && e('600,CNE服务器出错'); // 步骤1:正常实例和有效备份名查询恢复状态
r($cneTest->getRestoreStatusTest($instance999, 'backup-test')) && p('code,message') && e('404,Instance not found'); // 步骤2:不存在的实例ID查询恢复状态
r($cneTest->getRestoreStatusTest($instance0, 'backup-test')) && p('code,message') && e('404,Instance not found'); // 步骤3:无效实例ID(0)查询恢复状态
r($cneTest->getRestoreStatusTest($instance1, '')) && p('code,message') && e('400,Backup name cannot be empty'); // 步骤4:空备份名查询恢复状态
r($cneTest->getRestoreStatusTest($instanceNeg, 'backup-test')) && p('code,message') && e('404,Instance not found'); // 步骤5:负数实例ID查询恢复状态
@@ -1,33 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::getSettingsMapping();
timeout=0
cid=15623
- 执行cneTest模块的getSettingsMappingTest方法 属性admin_username @admin
- 执行cneTest模块的getSettingsMappingTest方法,参数是array 属性z_username @zentao_user
- 执行cneTest模块的getSettingsMappingTest方法,参数是array 属性custom_username @test_value_for_custom_username
- 执行cneTest模块的getSettingsMappingTest方法,参数是array 属性db_username @test_value_for_db_username
- 执行cneTest模块的getSettingsMappingTest方法,参数是array 属性invalid_key @test_value_for_invalid_key
*/
// 1. 导入依赖
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录
su('admin');
// 3. 创建测试实例
$cneTest = new cneModelTest();
// 4. 执行测试步骤
r($cneTest->getSettingsMappingTest()) && p('admin_username') && e('admin');
r($cneTest->getSettingsMappingTest(array())) && p('z_username') && e('zentao_user');
r($cneTest->getSettingsMappingTest(array(array('key' => 'custom_username', 'type' => 'helm', 'path' => 'auth.custom_username')))) && p('custom_username') && e('test_value_for_custom_username');
r($cneTest->getSettingsMappingTest(array(array('key' => 'db_username', 'type' => 'secret', 'path' => 'database.username'), array('key' => 'db_password', 'type' => 'secret', 'path' => 'database.password')))) && p('db_username') && e('test_value_for_db_username');
r($cneTest->getSettingsMappingTest(array(array('key' => 'invalid_key', 'type' => 'invalid_type', 'path' => 'invalid.path')))) && p('invalid_key') && e('test_value_for_invalid_key');
-29
View File
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::queryStatus();
timeout=0
cid=15626
- 执行cneTest模块的queryStatusTest方法,参数是1 属性code @0
- 执行cneTest模块的queryStatusTest方法,参数是999 @0
- 执行cneTest模块的queryStatusTest方法 @0
- 执行cneTest模块的queryStatusTest方法,参数是-1 @0
- 执行cneTest模块的queryStatusTest方法,参数是100 @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$cneTest = new cneModelTest();
r($cneTest->queryStatusTest(1)) && p('code') && e('0');
r($cneTest->queryStatusTest(999)) && p() && e('0');
r($cneTest->queryStatusTest(0)) && p() && e('0');
r($cneTest->queryStatusTest(-1)) && p() && e('0');
r($cneTest->queryStatusTest(100)) && p() && e('0');
-38
View File
@@ -1,38 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::sharedDBList();
timeout=0
cid=15628
- 执行cneTest模块的sharedDBListTest方法,参数是'' @0
- 执行cneTest模块的sharedDBListTest方法,参数是'mysql'
- 第zentaopaas-mysql条的name属性 @zentaopaas-mysql
- 第zentaopaas-mysql条的kind属性 @mysql
- 第zentaopaas-mysql条的port属性 @3306
- 执行cneTest模块的sharedDBListTest方法,参数是'postgresql'
- 第postgres-shared条的name属性 @postgres-shared
- 第postgres-shared条的kind属性 @postgresql
- 第postgres-shared条的port属性 @5432
- 执行cneTest模块的sharedDBListTest方法,参数是'mongodb' @0
- 执行cneTest模块的sharedDBListTest方法,参数是'redis'
- 第redis-cluster条的name属性 @redis-cluster
- 第redis-cluster条的kind属性 @redis
- 第redis-cluster条的port属性 @6379
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$cneTest = new cneModelTest();
r($cneTest->sharedDBListTest('')) && p() && e('0');
r($cneTest->sharedDBListTest('mysql')) && p('zentaopaas-mysql:name,kind,port') && e('zentaopaas-mysql,mysql,3306');
r($cneTest->sharedDBListTest('postgresql')) && p('postgres-shared:name,kind,port') && e('postgres-shared,postgresql,5432');
r($cneTest->sharedDBListTest('mongodb')) && p() && e('0');
r($cneTest->sharedDBListTest('redis')) && p('redis-cluster:name,kind,port') && e('redis-cluster,redis,6379');
-29
View File
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::startApp();
timeout=0
cid=15629
- 执行cneTest模块的startAppTest方法 属性code @200
- 执行cneTest模块的startAppWithEmptyChannelTest方法 第data条的channel属性 @stable
- 执行cneTest模块的startAppWithInvalidParamsTest方法 属性code @200
- 执行cneTest模块的startAppWithMissingParamsTest方法 属性code @200
- 执行cneTest模块的startAppWithNullParamsTest方法 @~~
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$cneTest = new cneModelTest();
r($cneTest->startAppTest()) && p('code') && e('200');
r($cneTest->startAppWithEmptyChannelTest()) && p('data:channel') && e('stable');
r($cneTest->startAppWithInvalidParamsTest()) && p('code') && e('200');
r($cneTest->startAppWithMissingParamsTest()) && p('code') && e('200');
r($cneTest->startAppWithNullParamsTest()) && p() && e('~~');
-62
View File
@@ -1,62 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::translateError();
timeout=0
cid=15631
- 执行cneTest模块的translateErrorTest方法,参数是$apiResult1 属性code @400
- 执行cneTest模块的translateErrorTest方法,参数是$apiResult2 属性code @404
- 执行cneTest模块的translateErrorTest方法,参数是$apiResult3 属性code @999
- 执行cneTest模块的translateErrorTest方法,参数是$apiResult4 属性code @41001
- 执行cneTest模块的translateErrorTest方法,参数是$apiResult5 属性code @40004
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
try {
include $initPath;
include $unitTestPath;
su('admin');
$useFramework = true;
} catch (Exception $e) {
// 框架初始化失败,使用独立模式
include $unitTestPath;
$useFramework = false;
}
$cneTest = new cneModelTest();
// 测试步骤1:已知错误代码400
$apiResult1 = new stdclass();
$apiResult1->code = 400;
$apiResult1->message = 'original error';
r($cneTest->translateErrorTest($apiResult1)) && p('code') && e('400');
// 测试步骤2:已知错误代码404
$apiResult2 = new stdclass();
$apiResult2->code = 404;
$apiResult2->message = 'not found';
r($cneTest->translateErrorTest($apiResult2)) && p('code') && e('404');
// 测试步骤3:未知错误代码999
$apiResult3 = new stdclass();
$apiResult3->code = 999;
$apiResult3->message = 'unknown error';
r($cneTest->translateErrorTest($apiResult3)) && p('code') && e('999');
// 测试步骤4:已知错误代码41001
$apiResult4 = new stdclass();
$apiResult4->code = 41001;
$apiResult4->message = 'certificate expired';
r($cneTest->translateErrorTest($apiResult4)) && p('code') && e('41001');
// 测试步骤5:已知错误代码40004
$apiResult5 = new stdclass();
$apiResult5->code = 40004;
$apiResult5->message = 'cert domain mismatch';
r($cneTest->translateErrorTest($apiResult5)) && p('code') && e('40004');
-29
View File
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel::updateConfig();
timeout=0
cid=15634
- 执行cneTest模块的updateConfigTest方法 @0
- 执行cneTest模块的updateConfigTest方法,参数是'2024.04.2401' @0
- 执行cneTest模块的updateConfigTest方法,参数是null, true @0
- 执行cneTest模块的updateConfigTest方法,参数是null, null, array @0
- 执行cneTest模块的updateConfigTest方法,参数是null, false, null, @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$cneTest = new cneModelTest();
r($cneTest->updateConfigTest()) && p() && e('0');
r($cneTest->updateConfigTest('2024.04.2401')) && p() && e('0');
r($cneTest->updateConfigTest(null, true)) && p() && e('0');
r($cneTest->updateConfigTest(null, null, array('key1' => 'value1'))) && p() && e('0');
r($cneTest->updateConfigTest(null, false, null, (object)array('setting1' => 'map1'))) && p() && e('0');
-55
View File
@@ -1,55 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel->validateDB();
timeout=0
cid=15638
- 空的数据
- 属性user @1
- 属性database @1
- 正确的数据库
- 属性user @1
- 属性database @1
- 正确的数据库和用户
- 属性user @1
- 属性database @1
- 正确的数据库、用户和数据库名
- 属性user @1
- 属性database @1
- 正确的所有数据,表名重复
- 属性user @1
- 属性database @~~
- 正确的数据库、用户、数据库名和表名
- 属性user @1
- 属性database @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
$cneModel = new cneModelTest();
$dbService = '';
$dbUser = '';
$dbName = '';
$namespace = '';
r($cneModel->validateDBTest($dbService, $dbUser, $dbName, $namespace)) && p('user,database') && e('1,1'); // 空的数据
$dbService = 'zentaopaas-mysql';
r($cneModel->validateDBTest($dbService, $dbUser, $dbName, $namespace)) && p('user,database') && e('1,1'); // 正确的数据库
$dbUser = 'root';
r($cneModel->validateDBTest($dbService, $dbUser, $dbName, $namespace)) && p('user,database') && e('1,1'); // 正确的数据库和用户
$dbName = 'zentaopaas';
r($cneModel->validateDBTest($dbService, $dbUser, $dbName, $namespace)) && p('user,database') && e('1,1'); // 正确的数据库、用户和数据库名
$namespace = 'quickon-system';
r($cneModel->validateDBTest($dbService, $dbUser, $dbName, $namespace)) && p('user,database') && e('~~,~~'); // 正确的所有数据,表名重复
$dbName = 'zentaopaas_test';
r($cneModel->validateDBTest($dbService, $dbUser, $dbName, $namespace)) && p('user,database') && e('~~,1'); // 正确的数据库、用户、数据库名和表名
+158 -28
View File
@@ -17,11 +17,7 @@ class commonModelTest extends baseTest
*/
public function apiErrorTest($result = null)
{
$reflection = new ReflectionClass('commonModel');
$method = $reflection->getMethod('apiError');
$method->setAccessible(true);
$result = $method->invoke(null, $result);
$result = $this->invokeArgs('apiError', [$result]);
if(dao::isError()) return dao::getError();
return $result;
}
@@ -43,37 +39,172 @@ class commonModelTest extends baseTest
}
/**
* Test printBack method metadata.
* Test canOperateEffort method.
*
* @param string $checkType
* @param object $effort
* @access public
* @return mixed
*/
public function printBackMetaTest(string $checkType)
public function canOperateEffortTest($effort = null)
{
if($checkType == 'exists')
{
return method_exists('commonModel', 'printBack') ? '1' : '0';
$result = $this->instance->canOperateEffort($effort);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test checkIP method.
*
* @param string $ipWhiteList
* @access public
* @return mixed
*/
public function checkIPTest($ipWhiteList = '')
{
$result = $this->instance->checkIP($ipWhiteList);
if(dao::isError()) return dao::getError();
return $result ? '1' : '0';
}
/**
* Test checkPrivByObject method.
*
* @param string $objectType
* @param int $objectID
* @access public
* @return bool
*/
public function checkPrivByObjectTest(string $objectType, int $objectID): bool
{
$result = $this->instance->checkPrivByObject($objectType, $objectID);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* 检查详情页操作按钮的权限。
* Check the privilege of the operate action.
*
* @param string $moduleName
* @param object $data
* @param object $menu
* @access protected
* @return array|bool
*/
public function checkPrivForOperateActionTest(string $moduleName, string $action, array $actionData)
{
$object = $this->instance->dao->select('*')->from($this->instance->config->objectTables[$moduleName])->where('id')->eq(1)->fetch();
$result = $this->instance->checkPrivForOperateAction($actionData, $action, $moduleName, $object, 'mainActions');
return is_array($result) ? !empty($result['url']) : $result;
}
/**
* Test createMenuLink method.
*
* @param object $menuItem
* @access public
* @return mixed
*/
public function createMenuLinkTest($menuItem)
{
$result = $this->instance->createMenuLink($menuItem);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test getDotStyle method.
*
* @param bool $showCount
* @param int $unreadCount
* @access public
* @return array
*/
public function getDotStyleTest(bool $showCount, int $unreadCount): array
{
$result = commonModel::getDotStyle($showCount, $unreadCount);
return $result;
}
/**
* Test getMainNavList method.
*
* @param string $moduleName
* @param bool $useDefault
* @access public
* @return mixed
*/
public function getMainNavListTest($moduleName, $useDefault = false)
{
$result = commonModel::getMainNavList($moduleName, $useDefault);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test isOpenMethod method.
*
* @param string $module
* @param string $method
* @access public
* @return bool
*/
public function isOpenMethodTest($module, $method)
{
$result = $this->objectModel->isOpenMethod($module, $method);
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test isTutorialMode method.
*
* @access public
* @return mixed
*/
public function isTutorialModeTest()
{
$result = commonModel::isTutorialMode();
if(dao::isError()) return dao::getError();
return $result ? '1' : '0';
}
/**
* Test setUser method.
*
* @param string $mode 测试模式:'guest'测试访客,'session'测试已登录用户
* @access public
* @return mixed
*/
public function setUserTest($mode = '')
{
// 如果指定测试guest模式,先清除session
if($mode === 'guest') {
if(isset($_SESSION['user'])) unset($_SESSION['user']);
if(isset($this->instance->app->user)) unset($app->user);
}
$reflection = new ReflectionMethod('commonModel', 'printBack');
// 执行setUser方法
$this->instance->setUser();
if(dao::isError()) return dao::getError();
if($checkType == 'static')
{
return $reflection->isStatic() ? '1' : '0';
}
// 返回结果
return $this->instance->app->user;
}
if($checkType == 'public')
{
return $reflection->isPublic() ? '1' : '0';
}
if($checkType == 'paramCount')
{
return (string)$reflection->getNumberOfParameters();
}
return '0';
/**
* Test strEndsWith method.
*
* @param string $haystack
* @param string $needle
* @access public
* @return bool
*/
public function strEndsWithTest($haystack, $needle)
{
$result = commonModel::strEndsWith($haystack, $needle);
if(dao::isError()) return dao::getError();
return $result;
}
/**
@@ -121,7 +252,6 @@ class commonModelTest extends baseTest
{
$result = commonModel::printDuration($seconds, $format);
if(dao::isError()) return dao::getError();
return $result;
}
-33
View File
@@ -1,33 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::apiDelete();
timeout=0
cid=15639
- 步骤1:成功删除请求属性code @200
- 步骤2:业务错误请求属性code @400
- 步骤3:空URL参数 @Empty URL
- 步骤4:超时错误请求属性code @600
- 步骤5:无效JSON响应属性code @600
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$commonTest = new commonModelTest();
// 4. 强制要求:必须包含至少5个测试步骤
r($commonTest->apiDeleteTest('https://api.example.com/success', array('id' => 123))) && p('code') && e('200'); // 步骤1:成功删除请求
r($commonTest->apiDeleteTest('https://api.example.com/error', array('id' => 456))) && p('code') && e('400'); // 步骤2:业务错误请求
r($commonTest->apiDeleteTest('', array('id' => 789))) && p() && e('Empty URL'); // 步骤3:空URL参数
r($commonTest->apiDeleteTest('https://api.example.com/timeout', array('id' => 999))) && p('code') && e('600'); // 步骤4:超时错误请求
r($commonTest->apiDeleteTest('https://api.example.com/invalid-json', array('id' => 111))) && p('code') && e('600'); // 步骤5:无效JSON响应
-29
View File
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::apiGet();
timeout=0
cid=15641
- 执行commonTest模块的apiGetTest方法,参数是'' @Empty URL
- 执行commonTest模块的apiGetTest方法,参数是'invalid-url' 属性code @600
- 执行commonTest模块的apiGetTest方法,参数是'http://api.success.com/test', array 属性code @200
- 执行commonTest模块的apiGetTest方法,参数是'http://api.error.com/test' 属性code @400
- 执行commonTest模块的apiGetTest方法,参数是'http://api.example.com/test' 属性code @600
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$commonTest = new commonModelTest();
r($commonTest->apiGetTest('')) && p() && e('Empty URL');
r($commonTest->apiGetTest('invalid-url')) && p('code') && e('600');
r($commonTest->apiGetTest('http://api.success.com/test', array('param' => 'value'))) && p('code') && e('200');
r($commonTest->apiGetTest('http://api.error.com/test')) && p('code') && e('400');
r($commonTest->apiGetTest('http://api.example.com/test')) && p('code') && e('600');
-28
View File
@@ -1,28 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::apiPost();
cid=15642
- 测试步骤1:正常POST请求 >> 期望返回code为200
- 测试步骤2:成功响应检查 >> 期望返回code为200且message为Success
- 测试步骤3:业务错误响应 >> 期望返回code为400且message为Bad Request
- 测试步骤4:空URL验证 >> 期望返回Empty URL错误信息
- 测试步骤5:无效URL格式验证 >> 期望返回code为600的错误
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$commonTest = new commonModelTest();
r($commonTest->apiPostTest('https://api.example.com/test', array('key' => 'value'))) && p('code') && e('200');
r($commonTest->apiPostTest('https://api.example.com/success', array('data' => 'test'))) && p('code,message') && e('200,Success');
r($commonTest->apiPostTest('https://api.example.com/error', array('action' => 'fail'))) && p('code,message') && e('400,Bad Request');
r($commonTest->apiPostTest('', array('empty' => 'url'))) && p() && e('Empty URL');
r($commonTest->apiPostTest('invalid-url', array('test' => 'data'))) && p('code') && e('600');
-33
View File
@@ -1,33 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::apiPut();
timeout=0
cid=15643
- 步骤1:正常成功请求属性code @200
- 步骤2:业务错误请求属性code @400
- 步骤3:无效URL属性code @600
- 步骤4:空URL @Empty URL
- 步骤5:带headers的请求属性code @200
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$commonTest = new commonModelTest();
// 4. 强制要求:必须包含至少5个测试步骤
r($commonTest->apiPutTest('https://api.example.com/success', array('key' => 'value'))) && p('code') && e('200'); // 步骤1:正常成功请求
r($commonTest->apiPutTest('https://api.example.com/error', array('key' => 'value'))) && p('code') && e('400'); // 步骤2:业务错误请求
r($commonTest->apiPutTest('invalid-url', array('key' => 'value'))) && p('code') && e('600'); // 步骤3:无效URL
r($commonTest->apiPutTest('', array('key' => 'value'))) && p() && e('Empty URL'); // 步骤4:空URL
r($commonTest->apiPutTest('https://api.example.com/success', array('data' => 'test'), array('Content-Type: application/json'))) && p('code') && e('200'); // 步骤5:带headers的请求
@@ -1,33 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::buildActionItem();
timeout=0
cid=15645
- 步骤1:测试有权限模块正常构建链接属性url @product-index-
- 步骤2:测试带属性参数的链接构建属性class @btn
- 步骤3:测试带title属性的链接构建属性title @查看
- 步骤4:测试带参数的URL构建属性url @product-view-id=1
- 步骤5:测试空模块名的异常处理 @0
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$commonTest = new commonModelTest();
// 4. 必须包含至少5个测试步骤
r($commonTest->buildActionItemTest('product', 'index', '')) && p('url') && e('product-index-'); // 步骤1:测试有权限模块正常构建链接
r($commonTest->buildActionItemTest('product', 'index', '', null, array('class' => 'btn'))) && p('class') && e('btn'); // 步骤2:测试带属性参数的链接构建
r($commonTest->buildActionItemTest('product', 'index', '', null, array('title' => '查看'))) && p('title') && e('查看'); // 步骤3:测试带title属性的链接构建
r($commonTest->buildActionItemTest('product', 'view', 'id=1')) && p('url') && e('product-view-id=1'); // 步骤4:测试带参数的URL构建
r($commonTest->buildActionItemTest('', 'index', '')) && p() && e('0'); // 步骤5:测试空模块名的异常处理
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::buildIconButton();
timeout=0
cid=15646
- 步骤1:验证方法存在 @1
- 步骤2:验证方法为静态方法 @1
- 步骤3:验证方法为公共方法 @1
- 步骤4:验证参数数量 @13
- 步骤5:验证第一个参数名称 @module
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$commonTest = new commonModelTest();
r($commonTest->buildIconButtonTest(1)) && p() && e('1'); // 步骤1:验证方法存在
r($commonTest->buildIconButtonTest(2)) && p() && e('1'); // 步骤2:验证方法为静态方法
r($commonTest->buildIconButtonTest(3)) && p() && e('1'); // 步骤3:验证方法为公共方法
r($commonTest->buildIconButtonTest(4)) && p() && e('13'); // 步骤4:验证参数数量
r($commonTest->buildIconButtonTest(5)) && p() && e('module'); // 步骤5:验证第一个参数名称
@@ -1,47 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::buildMoreButton();
timeout=0
cid=15647
- 步骤1:不存在的executionID @0
- 步骤2:无效ID为0 @0
- 步骤3:负数ID @0
- 步骤4:Tutorial模式或正常模式 @0
- 步骤5:执行记录但同项目无其他执行 @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
zenData('user')->gen(5);
// 准备项目和执行数据
$project = zenData('project');
$project->id->range('1-10');
$project->name->range('项目{1-5},执行{6-10}');
$project->type->range('project{5},sprint{5}');
$project->parent->range('0{5},0{5}');
$project->project->range('0{5},1-5'); // 执行的project字段指向父项目
$project->grade->range('1{5},2{5}');
$project->deleted->range('0{10}');
$project->gen(10);
su('admin');
// 创建测试实例
$commonTest = new commonModelTest();
// 模拟Tutorial模式进行一个测试
$_SESSION['tutorialMode'] = true;
// 测试用例(5个测试步骤)
r($commonTest->buildMoreButtonTest(999, false)) && p() && e('0'); // 步骤1:不存在的executionID
r($commonTest->buildMoreButtonTest(0, false)) && p() && e('0'); // 步骤2:无效ID为0
r($commonTest->buildMoreButtonTest(-1, false)) && p() && e('0'); // 步骤3:负数ID
r($commonTest->buildMoreButtonTest(1, false)) && p() && e('0'); // 步骤4:Tutorial模式或正常模式
r($commonTest->buildMoreButtonTest(6, false)) && p() && e('0'); // 步骤5:执行记录但同项目无其他执行
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::buildOperateMenu();
timeout=0
cid=15648
- 步骤1:验证方法存在 @1
- 步骤2:验证方法为公共方法 @1
- 步骤3:验证第一个参数为object类型 @1
- 步骤4:验证第二个参数为string类型 @1
- 步骤5:验证参数数量 @2
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$commonTest = new commonModelTest();
r($commonTest->testBuildOperateMenuSignature(1)) && p() && e('1'); // 步骤1:验证方法存在
r($commonTest->testBuildOperateMenuSignature(2)) && p() && e('1'); // 步骤2:验证方法为公共方法
r($commonTest->testBuildOperateMenuSignature(3)) && p() && e('1'); // 步骤3:验证第一个参数为object类型
r($commonTest->testBuildOperateMenuSignature(4)) && p() && e('1'); // 步骤4:验证第二个参数为string类型
r($commonTest->testBuildOperateMenuSignature(5)) && p() && e('2'); // 步骤5:验证参数数量
-42
View File
@@ -1,42 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::checkEntry();
timeout=0
cid=15652
- 测试步骤1:缺少模块参数 @EMPTY_ENTRY
- 测试步骤2:缺少方法参数 @EMPTY_ENTRY
- 测试步骤3:访问开放方法misc.about @1
- 测试步骤4:缺少code参数 @PARAM_CODE_MISSING
- 测试步骤5:缺少token参数 @PARAM_TOKEN_MISSING
- 测试步骤6:code不存在 @EMPTY_ENTRY
- 测试步骤7:entry的key为空 @EMPTY_KEY
- 测试步骤8:IP地址被拒绝 @IP_DENIED
- 测试步骤9:token无效 @INVALID_TOKEN
- 测试步骤10:账户未绑定 @ACCOUNT_UNBOUND
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
zenData('entry')->loadYaml('checkentry/entry', false, 2)->gen(10);
zenData('user')->loadYaml('checkentry/user', false, 2)->gen(10);
su('admin');
$commonTest = new commonModelTest();
r($commonTest->checkEntryTest('', '', '', '')) && p() && e('EMPTY_ENTRY'); // 测试步骤1:缺少模块参数
r($commonTest->checkEntryTest('user', '', '', '')) && p() && e('EMPTY_ENTRY'); // 测试步骤2:缺少方法参数
r($commonTest->checkEntryTest('misc', 'about', '', '')) && p() && e('1'); // 测试步骤3:访问开放方法misc.about
r($commonTest->checkEntryTest('user', 'login', '', '')) && p() && e('PARAM_CODE_MISSING'); // 测试步骤4:缺少code参数
r($commonTest->checkEntryTest('user', 'login', 'validcode', '')) && p() && e('PARAM_TOKEN_MISSING'); // 测试步骤5:缺少token参数
r($commonTest->checkEntryTest('user', 'login', 'nonexistcode', 'token123')) && p() && e('EMPTY_ENTRY'); // 测试步骤6:code不存在
r($commonTest->checkEntryTest('user', 'login', 'nokey', 'token123')) && p() && e('EMPTY_KEY'); // 测试步骤7:entry的key为空
r($commonTest->checkEntryTest('user', 'login', 'validip', 'token123')) && p() && e('IP_DENIED'); // 测试步骤8:IP地址被拒绝
r($commonTest->checkEntryTest('user', 'login', 'invalidtoken', 'token123')) && p() && e('INVALID_TOKEN'); // 测试步骤9:token无效
r($commonTest->checkEntryTest('user', 'login', 'unboundaccount', 'token123')) && p() && e('ACCOUNT_UNBOUND'); // 测试步骤10:账户未绑定
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::checkMenuVarsReplaced();
timeout=0
cid=15658
- 执行commonTest模块的checkMenuVarsReplacedTest方法,参数是1 @public_static_method
- 执行commonTest模块的checkMenuVarsReplacedTest方法,参数是2 @no_return_type
- 执行commonTest模块的checkMenuVarsReplacedTest方法,参数是3 @no_parameters
- 执行commonTest模块的checkMenuVarsReplacedTest方法,参数是4 @has_doc_comment
- 执行commonTest模块的checkMenuVarsReplacedTest方法,参数是5 @correct_signature
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$commonTest = new commonModelTest();
r($commonTest->checkMenuVarsReplacedTest(1)) && p() && e('public_static_method');
r($commonTest->checkMenuVarsReplacedTest(2)) && p() && e('no_return_type');
r($commonTest->checkMenuVarsReplacedTest(3)) && p() && e('no_parameters');
r($commonTest->checkMenuVarsReplacedTest(4)) && p() && e('has_doc_comment');
r($commonTest->checkMenuVarsReplacedTest(5)) && p() && e('correct_signature');
-33
View File
@@ -1,33 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::checkNotCN();
timeout=0
cid=15659
- 步骤1:中文简体 @0
- 步骤2:中文繁体 @0
- 步骤3:英语 @1
- 步骤4:德语 @1
- 步骤5:法语 @1
- 步骤6:空语言 @0
- 步骤7:未知语言 @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$commonTest = new commonModelTest();
r($commonTest->checkNotCNTest('zh-cn')) && p() && e('0'); // 步骤1:中文简体
r($commonTest->checkNotCNTest('zh-tw')) && p() && e('0'); // 步骤2:中文繁体
r($commonTest->checkNotCNTest('en')) && p() && e('1'); // 步骤3:英语
r($commonTest->checkNotCNTest('de')) && p() && e('1'); // 步骤4:德语
r($commonTest->checkNotCNTest('fr')) && p() && e('1'); // 步骤5:法语
r($commonTest->checkNotCNTest('')) && p() && e('0'); // 步骤6:空语言(默认为zh-cn)
r($commonTest->checkNotCNTest('test')) && p() && e('1'); // 步骤7:未知语言
@@ -1,37 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::checkUpgradeStatus();
timeout=0
cid=15664
- 步骤1:测试checkUpgradeStatus正常调用情况 @1
- 步骤2:测试容器环境下的行为 @1
- 步骤3:测试有安全文件的情况 @1
- 步骤4:测试升级过程中的行为 @1
- 步骤5:测试输出缓冲区处理 @1
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
try {
su('admin');
} catch (Exception $e) {
// 在某些测试环境中,用户登录可能失败,我们继续执行测试
}
// 3. 创建测试实例(变量名与模块名一致)
$commonTest = new commonModelTest();
// 4. 🔴 强制要求:必须包含至少5个测试步骤
r($commonTest->checkUpgradeStatusTest()) && p() && e('1'); // 步骤1:测试checkUpgradeStatus正常调用情况
r($commonTest->checkUpgradeStatusTest('container')) && p() && e('1'); // 步骤2:测试容器环境下的行为
r($commonTest->checkUpgradeStatusTest('safefile')) && p() && e('1'); // 步骤3:测试有安全文件的情况
r($commonTest->checkUpgradeStatusTest('upgrading')) && p() && e('1'); // 步骤4:测试升级过程中的行为
r($commonTest->checkUpgradeStatusTest('outputbuffer')) && p() && e('1'); // 步骤5:测试输出缓冲区处理
@@ -1,33 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::getActiveMainMenu();
timeout=0
cid=15672
- 步骤1:验证方法基本功能-产品模块场景 @method_validated
- 步骤2:验证方法基本功能-空模块场景 @method_validated
- 步骤3:验证方法基本功能-项目模块场景 @method_validated
- 步骤4:验证方法基本功能-执行模块场景 @method_validated
- 步骤5:验证方法基本功能-缺陷模块场景 @method_validated
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$commonTest = new commonModelTest();
// 4. 🔴 强制要求:必须包含至少5个测试步骤
r($commonTest->getActiveMainMenuTest(1)) && p() && e('method_validated'); // 步骤1:验证方法基本功能-产品模块场景
r($commonTest->getActiveMainMenuTest(2)) && p() && e('method_validated'); // 步骤2:验证方法基本功能-空模块场景
r($commonTest->getActiveMainMenuTest(3)) && p() && e('method_validated'); // 步骤3:验证方法基本功能-项目模块场景
r($commonTest->getActiveMainMenuTest(4)) && p() && e('method_validated'); // 步骤4:验证方法基本功能-执行模块场景
r($commonTest->getActiveMainMenuTest(5)) && p() && e('method_validated'); // 步骤5:验证方法基本功能-缺陷模块场景
@@ -1,40 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::getHasPrivLink();
timeout=0
cid=1
- 测试空数据 @0
- 测试获取有权限的需求链接
- 属性1 @my
- 属性2 @contribute
- 测试获取有权限的产品链接
- 属性1 @product
- 属性2 @all
- 测试获取有权限的项目链接
- 属性1 @project
- 属性2 @browse
- 测试获取有权限的质量保证计划
- 属性1 @auditplan
- 属性2 @browse
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$commonTest = new commonModelTest();
$menuList[] = array();
$menuList[] = array('link' => '需求|my|contribute|mode=story');
$menuList[] = array('link' => '产品|product|all|');
$menuList[] = array('link' => '项目列表|project|browse|');
$menuList[] = array('link' => '质量保证计划|auditplan|browse|projectID=%s', 'links' => array('project|deliverableChecklist|projectID=%s', 'nc|browse|project=%s&from=project'));
r($commonTest->getHasPrivLinkTest($menuList[0])) && p() && e('0'); // 测试空数据
r($commonTest->getHasPrivLinkTest($menuList[1])) && p('1,2') && e('my,contribute'); // 测试获取有权限的需求链接
r($commonTest->getHasPrivLinkTest($menuList[2])) && p('1,2') && e('product,all'); // 测试获取有权限的产品链接
r($commonTest->getHasPrivLinkTest($menuList[3])) && p('1,2') && e('project,browse'); // 测试获取有权限的项目链接
r($commonTest->getHasPrivLinkTest($menuList[4])) && p('1,2') && e('auditplan,browse'); // 测试获取有权限的质量保证计划
-36
View File
@@ -1,36 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::getSysURL();
timeout=0
cid=15677
- 执行commonTest模块的getSysURLTest方法,参数是1 @0
- 执行commonTest模块的getSysURLTest方法,参数是2 @https://example.com
- 执行commonTest模块的getSysURLTest方法,参数是3 @http://example.com
- 执行commonTest模块的getSysURLTest方法,参数是4 @https://example.com
- 执行commonTest模块的getSysURLTest方法,参数是5 @https://example.com
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
$commonTest = new commonModelTest();
// 测试模式下返回空字符串
r($commonTest->getSysURLTest(1)) && p() && e('0');
// 模拟HTTPS环境测试
r($commonTest->getSysURLTest(2)) && p() && e('https://example.com');
// 模拟HTTP环境测试
r($commonTest->getSysURLTest(3)) && p() && e('http://example.com');
// 模拟X-Forwarded-Proto头部测试
r($commonTest->getSysURLTest(4)) && p() && e('https://example.com');
// 模拟REQUEST_SCHEME头部测试
r($commonTest->getSysURLTest(5)) && p() && e('https://example.com');
-32
View File
@@ -1,32 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
zenData('company')->gen(1);
zenData('user')->gen(5);
su('admin');
/**
title=测试 commonModel::getUserPriv();
timeout=0
cid=15678
- 执行commonTest模块的getUserPrivTest方法,参数是'user', 'browse', null, '', 'nouser' @0
- 执行commonTest模块的getUserPrivTest方法,参数是'user', 'browse', null, '', 'admin' @1
- 执行commonTest模块的getUserPrivTest方法,参数是'user', 'browse', null, '', 'openmethod' @1
- 执行commonTest模块的getUserPrivTest方法,参数是'user', 'browse', null, '', 'hasrights' @1
- 执行commonTest模块的getUserPrivTest方法,参数是'task', 'create', null, '', 'norights' @0
*/
include dirname(__FILE__, 2) . '/lib/model.class.php';
$commonTest = new commonModelTest();
r($commonTest->getUserPrivTest('user', 'browse', null, '', 'nouser')) && p() && e('0');
r($commonTest->getUserPrivTest('user', 'browse', null, '', 'admin')) && p() && e('1');
r($commonTest->getUserPrivTest('user', 'browse', null, '', 'openmethod')) && p() && e('1');
r($commonTest->getUserPrivTest('user', 'browse', null, '', 'hasrights')) && p() && e('1');
r($commonTest->getUserPrivTest('task', 'create', null, '', 'norights')) && p() && e('0');
-32
View File
@@ -1,32 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::http();
timeout=0
cid=15681
- 执行commonTest模块的httpTest方法,参数是'https://example.com/api', null, array @GET response data
- 执行commonTest模块的httpTest方法,参数是'https://example.com/api', array @POST response with data
- 执行commonTest模块的httpTest方法,参数是'https://example.com/json/api', array @{"status":"success","data":"test"}
- 执行commonTest模块的httpTest方法,参数是'https://example.com/httpcode/api', null, array 属性1 @201
- 执行commonTest模块的httpTest方法,参数是'', null, array @0
- 执行commonTest模块的httpTest方法,参数是'https://example.com/api', array @PUT response
- 执行commonTest模块的httpTest方法,参数是'https://example.com/error/api', null, array @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
$commonTest = new commonModelTest();
r($commonTest->httpTest('https://example.com/api', null, array(), array(), 'data', 'GET')) && p() && e('GET response data');
r($commonTest->httpTest('https://example.com/api', array('name' => 'test'), array(), array(), 'data', 'POST')) && p() && e('POST response with data');
r($commonTest->httpTest('https://example.com/json/api', array('data' => 'test'), array(), array(), 'json', 'POST')) && p() && e('{"status":"success","data":"test"}');
r($commonTest->httpTest('https://example.com/httpcode/api', null, array(), array(), 'data', 'POST', 30, true)) && p('1') && e('201');
r($commonTest->httpTest('', null, array(), array(), 'data', 'POST')) && p() && e('0');
r($commonTest->httpTest('https://example.com/api', array('update' => 'data'), array(), array(), 'data', 'PUT')) && p() && e('PUT response');
r($commonTest->httpTest('https://example.com/error/api', null, array(), array(), 'data', 'GET')) && p() && e('0');
@@ -1,30 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::initAuthorize();
timeout=0
cid=15682
- 步骤1:无用户登录情况属性result @0
- 步骤2:升级过程中的用户属性result @1
- 步骤3:正常用户登录非升级状态属性result @1
- 步骤4:普通用户权限初始化属性result @1
- 步骤5:guest用户权限初始化属性result @1
*/
// 1. 导入依赖
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 创建测试实例
$commonTest = new commonModelTest();
// 3. 测试步骤
r($commonTest->initAuthorizeTest('', false)) && p('result') && e('0'); // 步骤1:无用户登录情况
r($commonTest->initAuthorizeTest('admin', true)) && p('result') && e('1'); // 步骤2:升级过程中的用户
r($commonTest->initAuthorizeTest('admin', false)) && p('result') && e('1'); // 步骤3:正常用户登录非升级状态
r($commonTest->initAuthorizeTest('user1', false)) && p('result') && e('1'); // 步骤4:普通用户权限初始化
r($commonTest->initAuthorizeTest('guest', false)) && p('result') && e('1'); // 步骤5:guest用户权限初始化
@@ -1,27 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
/**
title=测试 commonModel::printAboutBar();
timeout=0
cid=15688
- 步骤1:验证方法存在 @1
- 步骤2:验证方法为静态方法 @1
- 步骤3:验证方法为公共方法 @1
- 步骤4:验证参数数量为0 @1
- 步骤5:验证方法可以被调用 @1
*/
$commonTest = new commonModelTest();
r($commonTest->printAboutBarTest(1)) && p() && e('1'); // 步骤1:验证方法存在
r($commonTest->printAboutBarTest(2)) && p() && e('1'); // 步骤2:验证方法为静态方法
r($commonTest->printAboutBarTest(3)) && p() && e('1'); // 步骤3:验证方法为公共方法
r($commonTest->printAboutBarTest(4)) && p() && e('1'); // 步骤4:验证参数数量为0
r($commonTest->printAboutBarTest(5)) && p() && e('1'); // 步骤5:验证方法可以被调用
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::printClientLink();
timeout=0
cid=15690
- 步骤1:两个配置都启用 @1
- 步骤2:仅xxserver安装 @0
- 步骤3:仅xuanxuan开启 @0
- 步骤4:两个都禁用 @0
- 步骤5:xxserver未设置 @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$commonTest = new commonModelTest();
r($commonTest->printClientLinkTest('both_enabled')) && p() && e('1'); // 步骤1:两个配置都启用
r($commonTest->printClientLinkTest('xxserver_only')) && p() && e('0'); // 步骤2:仅xxserver安装
r($commonTest->printClientLinkTest('xuanxuan_only')) && p() && e('0'); // 步骤3:仅xuanxuan开启
r($commonTest->printClientLinkTest('both_disabled')) && p() && e('0'); // 步骤4:两个都禁用
r($commonTest->printClientLinkTest('xxserver_not_set')) && p() && e('0'); // 步骤5:xxserver未设置
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::printCreateList();
timeout=0
cid=15692
- 执行commonTest模块的printCreateListTest方法,参数是1 @1
- 执行commonTest模块的printCreateListTest方法,参数是2 @1
- 执行commonTest模块的printCreateListTest方法,参数是3 @1
- 执行commonTest模块的printCreateListTest方法,参数是4 @1
- 执行commonTest模块的printCreateListTest方法,参数是5 @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$commonTest = new commonModelTest();
r($commonTest->printCreateListTest(1)) && p() && e('1');
r($commonTest->printCreateListTest(2)) && p() && e('1');
r($commonTest->printCreateListTest(3)) && p() && e('1');
r($commonTest->printCreateListTest(4)) && p() && e('1');
r($commonTest->printCreateListTest(5)) && p() && e('1');
-33
View File
@@ -1,33 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::printIcon();
timeout=0
cid=15695
- 步骤1:验证方法存在 @1
- 步骤2:验证方法为静态方法 @1
- 步骤3:验证方法为公共方法 @1
- 步骤4:验证参数数量 @13
- 步骤5:验证方法功能调用buildIconButton @1
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$commonTest = new commonModelTest();
// 4. 🔴 强制要求:必须包含至少5个测试步骤
r($commonTest->printIconTest(1)) && p() && e('1'); // 步骤1:验证方法存在
r($commonTest->printIconTest(2)) && p() && e('1'); // 步骤2:验证方法为静态方法
r($commonTest->printIconTest(3)) && p() && e('1'); // 步骤3:验证方法为公共方法
r($commonTest->printIconTest(4)) && p() && e('13'); // 步骤4:验证参数数量
r($commonTest->printIconTest(5)) && p() && e('1'); // 步骤5:验证方法功能调用buildIconButton
-27
View File
@@ -1,27 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::printLink();
timeout=0
cid=15696
- 执行commonTest模块的printLinkTest方法,参数是'misc', 'ping', '', 'Ping', '', '', true, false, null 属性result @1
- 执行commonTest模块的printLinkTest方法,参数是'admin', 'forbidden', '', 'Forbidden', '', '', true, false, null @0
- 执行commonTest模块的printLinkTest方法,参数是'user', 'login', '', 'Login', '', '', true, false, null 属性result @1
- 执行commonTest模块的printLinkTest方法,参数是'task', 'view', 'taskID=123', 'View Task', '_blank', 'class="btn"', true, false, null 属性result @1
- 执行commonTest模块的printLinkTest方法,参数是'project', 'browse', '', 'Projects', '', 'id="project-link"', true, false, null 属性result @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
$commonTest = new commonModelTest();
r($commonTest->printLinkTest('misc', 'ping', '', 'Ping', '', '', true, false, null)) && p('result') && e('1');
r($commonTest->printLinkTest('admin', 'forbidden', '', 'Forbidden', '', '', true, false, null)) && p() && e('0');
r($commonTest->printLinkTest('user', 'login', '', 'Login', '', '', true, false, null)) && p('result') && e('1');
r($commonTest->printLinkTest('task', 'view', 'taskID=123', 'View Task', '_blank', 'class="btn"', true, false, null)) && p('result') && e('1');
r($commonTest->printLinkTest('project', 'browse', '', 'Projects', '', 'id="project-link"', true, false, null)) && p('result') && e('1');
@@ -1,27 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::printOrderLink();
timeout=0
cid=15700
- 步骤1:基本排序链接生成 @<a href='/user-browse-orderBy=id_asc.html' class='header' data-app=system>ID</a>
- 步骤2:当前字段升序排序链接 @<a href='/user-browse-orderBy=id_desc.html' class='sort-up' data-app=system>ID</a>
- 步骤3:当前字段降序排序链接 @<a href='/user-browse-orderBy=id_asc.html' class='sort-down' data-app=system>ID</a>
- 步骤4:移动端排序链接生成 @<a href='/task-browse-orderBy=name_asc.html' class='header' data-app=system>Name</a>
- 步骤5:带反引号字段名处理 @<a href='/bug-browse-orderBy=status_asc.html' class='sort-down' data-app=system>Status</a>
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
$commonTest = new commonModelTest();
r($commonTest->printOrderLinkTest('id', 'name_asc', 'orderBy=%s', 'ID', 'user', 'browse')) && p() && e("<a href='/user-browse-orderBy=id_asc.html' class='header' data-app=system>ID</a>"); // 步骤1:基本排序链接生成
r($commonTest->printOrderLinkTest('id', 'id_asc', 'orderBy=%s', 'ID', 'user', 'browse')) && p() && e("<a href='/user-browse-orderBy=id_desc.html' class='sort-up' data-app=system>ID</a>"); // 步骤2:当前字段升序排序链接
r($commonTest->printOrderLinkTest('id', 'id_desc', 'orderBy=%s', 'ID', 'user', 'browse')) && p() && e("<a href='/user-browse-orderBy=id_asc.html' class='sort-down' data-app=system>ID</a>"); // 步骤3:当前字段降序排序链接
r($commonTest->printOrderLinkTest('name', 'id_asc', 'orderBy=%s', 'Name', 'task', 'browse', 'mhtml')) && p() && e("<a href='/task-browse-orderBy=name_asc.html' class='header' data-app=system>Name</a>"); // 步骤4:移动端排序链接生成
r($commonTest->printOrderLinkTest('status', '`status`_desc', 'orderBy=%s', 'Status', 'bug', 'browse')) && p() && e("<a href='/bug-browse-orderBy=status_asc.html' class='sort-down' data-app=system>Status</a>"); // 步骤5:带反引号字段名处理
-27
View File
@@ -1,27 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
/**
title=测试 commonModel::printUserBar();
timeout=0
cid=15702
- 步骤1:验证方法存在 @1
- 步骤2:验证方法为静态方法 @1
- 步骤3:验证方法为公共方法 @1
- 步骤4:验证参数数量为0 @1
- 步骤5:验证方法可以被调用 @1
*/
$commonTest = new commonModelTest();
r($commonTest->printUserBarTest(1)) && p() && e('1'); // 步骤1:验证方法存在
r($commonTest->printUserBarTest(2)) && p() && e('1'); // 步骤2:验证方法为静态方法
r($commonTest->printUserBarTest(3)) && p() && e('1'); // 步骤3:验证方法为公共方法
r($commonTest->printUserBarTest(4)) && p() && e('1'); // 步骤4:验证参数数量为0
r($commonTest->printUserBarTest(5)) && p() && e('1'); // 步骤5:验证方法可以被调用
-44
View File
@@ -1,44 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::sendHeader();
timeout=0
cid=15708
- 执行$commonTest->objectModel, 'sendHeader' @1
- 执行commonTest模块的sendHeaderTest方法,参数是'basic' @1
- 执行commonTest模块的sendHeaderTest方法,参数是'security_headers' @1
- 执行commonTest模块的sendHeaderTest方法,参数是'csp' @1
- 执行commonTest模块的sendHeaderTest方法,参数是'xframe' @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 创建测试实例
$commonTest = new commonModelTest();
// 备份原始配置
global $config;
$originalCharset = isset($config->charset) ? $config->charset : 'UTF-8';
$originalFramework = isset($config->framework) ? clone $config->framework : new stdClass();
$originalCSPs = isset($config->CSPs) ? $config->CSPs : array();
$originalXFrameOptions = isset($config->xFrameOptions) ? $config->xFrameOptions : '';
// 确保framework配置对象存在
if(!isset($config->framework)) $config->framework = new stdClass();
r(method_exists($commonTest->objectModel, 'sendHeader')) && p() && e(1);
r($commonTest->sendHeaderTest('basic')) && p() && e(1);
r($commonTest->sendHeaderTest('security_headers')) && p() && e(1);
r($commonTest->sendHeaderTest('csp')) && p() && e(1);
r($commonTest->sendHeaderTest('xframe')) && p() && e(1);
// 恢复原始配置
$config->charset = $originalCharset;
$config->framework = $originalFramework;
$config->CSPs = $originalCSPs;
$config->xFrameOptions = $originalXFrameOptions;
-33
View File
@@ -1,33 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::setMainMenu();
timeout=0
cid=15711
- 步骤1:验证方法存在性 @method_exists
- 步骤2:验证方法为静态方法 @is_static
- 步骤3:验证返回类型为bool @return_bool
- 步骤4:验证无参数要求 @no_parameters
- 步骤5:验证方法为公共可访问 @is_public
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$commonTest = new commonModelTest();
// 4. 强制要求:必须包含至少5个测试步骤
r($commonTest->setMainMenuTest(1)) && p() && e('method_exists'); // 步骤1:验证方法存在性
r($commonTest->setMainMenuTest(2)) && p() && e('is_static'); // 步骤2:验证方法为静态方法
r($commonTest->setMainMenuTest(3)) && p() && e('return_bool'); // 步骤3:验证返回类型为bool
r($commonTest->setMainMenuTest(4)) && p() && e('no_parameters'); // 步骤4:验证无参数要求
r($commonTest->setMainMenuTest(5)) && p() && e('is_public'); // 步骤5:验证方法为公共可访问
-33
View File
@@ -1,33 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::setMenuVars();
timeout=0
cid=15712
- 步骤1:正常情况 @browse-123
- 步骤2:带html后缀链接 @view-456.html
- 步骤3:webMenu模式 @browse-789
- 步骤4:空菜单项跳过 @browse-999
- 步骤5:homeMenu删除 @1
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$commonTest = new commonModelTest();
// 4. 强制要求:必须包含至少5个测试步骤
r($commonTest->setMenuVarsTest(1)) && p() && e('browse-123'); // 步骤1:正常情况
r($commonTest->setMenuVarsTest(2)) && p() && e('view-456.html'); // 步骤2:带html后缀链接
r($commonTest->setMenuVarsTest(3)) && p() && e('browse-789'); // 步骤3:webMenu模式
r($commonTest->setMenuVarsTest(4)) && p() && e('browse-999'); // 步骤4:空菜单项跳过
r($commonTest->setMenuVarsTest(5)) && p() && e('1'); // 步骤5:homeMenu删除
@@ -1,47 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
su('admin');
/**
title=测试 commonModel::setMenuVarsEx();
timeout=0
cid=15713
- 查看替换后的菜单链接 @/execution-task-1
- 查看替换后的菜单链接属性link @/task-create-1
- 查看替换后的菜单链接属性link @/task-edit-1
- 查看替换后的菜单链接属性link @/task-delete-1
- 查看替换后的菜单链接属性link @/task-view-1
*/
$menu = "/execution-task-%s";
$menu = common::setMenuVarsEx($menu, 1);
r($menu) && p() && e('/execution-task-1'); // 查看替换后的菜单链接
$menu = array();
$menu['link'] = "/task-create-%s";
$menu = common::setMenuVarsEx($menu, 1);
r($menu) && p('link') && e('/task-create-1'); // 查看替换后的菜单链接
$menu = array();
$menu['link'] = "/task-edit-%s";
$menu = common::setMenuVarsEx($menu, 1);
r($menu) && p('link') && e('/task-edit-1'); // 查看替换后的菜单链接
$menu = array();
$menu['link'] = "/task-delete-%s";
$menu = common::setMenuVarsEx($menu, 1);
r($menu) && p('link') && e('/task-delete-1'); // 查看替换后的菜单链接
$menu = array();
$menu['link'] = "/task-view-%s";
$menu = common::setMenuVarsEx($menu, 1);
r($menu) && p('link') && e('/task-view-1'); // 查看替换后的菜单链接
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::sortFeatureMenu();
timeout=0
cid=15716
- 执行commonTest模块的sortFeatureMenuTest方法,参数是1 @1
- 执行commonTest模块的sortFeatureMenuTest方法,参数是2 @1
- 执行commonTest模块的sortFeatureMenuTest方法,参数是3 @1
- 执行commonTest模块的sortFeatureMenuTest方法,参数是4 @2
- 执行commonTest模块的sortFeatureMenuTest方法,参数是5 @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$commonTest = new commonModelTest();
r($commonTest->sortFeatureMenuTest(1)) && p() && e('1');
r($commonTest->sortFeatureMenuTest(2)) && p() && e('1');
r($commonTest->sortFeatureMenuTest(3)) && p() && e('1');
r($commonTest->sortFeatureMenuTest(4)) && p() && e('2');
r($commonTest->sortFeatureMenuTest(5)) && p() && e('1');
@@ -24,11 +24,11 @@ cid=15704
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
include dirname(__FILE__, 2) . '/lib/tao.class.php';
su('admin');
$commonTest = new commonModelTest();
$commonTest = new commonTaoTest();
// 步骤1:测试没有 custom 数据时的处理
global $lang;
@@ -75,4 +75,4 @@ if(!isset($lang->bug)) $lang->bug = new stdClass();
if(!isset($lang->bug->menu)) $lang->bug->menu = new stdClass();
$lang->bug->menu->view = array('link' => '查看|bug|view|bugID=%s');
r($commonTest->replaceMenuLangTest()) && p() && e('0');
r($lang->bug->menu->view['link']) && p() && e('Bug查看|bug|view|bugID=%s');
r($lang->bug->menu->view['link']) && p() && e('Bug查看|bug|view|bugID=%s');
File diff suppressed because it is too large Load Diff