Merge branch release/22.0.beta of zentao/zentaopms (#13305)
This commit is contained in:
@@ -989,25 +989,7 @@ class actionModelTest extends baseTest
|
||||
*/
|
||||
public function getObjectTypeTeamParamsTest($action)
|
||||
{
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('getObjectTypeTeamParams');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->instance, $action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processAttribute method.
|
||||
*
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function processAttributeTest(string $type): string
|
||||
{
|
||||
$result = $this->objectTao->processAttribute($type);
|
||||
$result = $this->invokeArgs('getObjectTypeTeamParams', [$action]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
@@ -1022,386 +1004,7 @@ class actionModelTest extends baseTest
|
||||
*/
|
||||
public function checkActionCanUndeleteTest($action, $object)
|
||||
{
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('checkActionCanUndelete');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->instance, $action, $object);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getLinkedExtra method.
|
||||
*
|
||||
* @param object $action
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function getLinkedExtraTest(object $action, string $type): bool
|
||||
{
|
||||
$result = $this->objectTao->getLinkedExtra($action, $type);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processActionExtra method.
|
||||
*
|
||||
* @param string $table
|
||||
* @param int $extraID
|
||||
* @param string $fields
|
||||
* @param string $type
|
||||
* @param string $method
|
||||
* @param bool $onlyBody
|
||||
* @param bool $addLink
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function processActionExtraTest(string $table, int $extraID, string $fields, string $type, string $method = 'view', bool $onlyBody = false, bool $addLink = true): string
|
||||
{
|
||||
// 创建测试用的action对象
|
||||
$action = new stdClass();
|
||||
$action->extra = $extraID;
|
||||
$action->objectType = 'bug';
|
||||
$action->action = 'converttotask';
|
||||
$action->project = 1;
|
||||
|
||||
$originalExtra = $action->extra; // 备份原始extra值
|
||||
|
||||
// 模拟onlyBody场景
|
||||
if($onlyBody)
|
||||
{
|
||||
$originalIsonlybody = $this->instance->config->requestType ?? 'GET';
|
||||
$_GET['onlybody'] = 'yes';
|
||||
}
|
||||
|
||||
$this->objectTao->processActionExtra($table, $action, $fields, $type, $method, $onlyBody, $addLink);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
if($onlyBody) unset($_GET['onlybody']); // 恢复onlyBody状态
|
||||
|
||||
// 分析结果 - 优先检查特殊场景
|
||||
if($action->extra == $originalExtra) return 'no_change';
|
||||
if($onlyBody && strpos($action->extra, '<a') === false) return 'onlybody_mode';
|
||||
if(!$addLink && strpos($action->extra, '#') !== false && strpos($action->extra, '<a') === false) return 'no_link';
|
||||
if($action->objectType == 'bug' && $type == 'task' && strpos($action->extra, 'data-app=') !== false) return 'bug_to_task';
|
||||
if(strpos($action->extra, '<a') !== false) return 'contains_link';
|
||||
return 'processed';
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processStoryGradeActionExtra method.
|
||||
*
|
||||
* @param int $storyID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processStoryGradeActionExtraTest(int $storyID): object
|
||||
{
|
||||
// 创建测试用的action对象
|
||||
$action = new stdClass();
|
||||
$action->objectID = $storyID;
|
||||
$action->extra = '';
|
||||
|
||||
$result = $this->objectTao->processStoryGradeActionExtra($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processParamString method.
|
||||
*
|
||||
* @param object $action
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function processParamStringTest(object $action, string $type): string
|
||||
{
|
||||
$result = $this->objectTao->processParamString($action, $type);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processCreateChildrenActionExtra method.
|
||||
*
|
||||
* @param string $taskIds
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processCreateChildrenActionExtraTest(string $taskIds): object
|
||||
{
|
||||
// 创建模拟的action对象
|
||||
$action = new stdClass();
|
||||
$action->extra = $taskIds;
|
||||
|
||||
$this->objectTao->processCreateChildrenActionExtra($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processCreateRequirementsActionExtra method.
|
||||
*
|
||||
* @param string $storyIds
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processCreateRequirementsActionExtraTest(string $storyIds): object
|
||||
{
|
||||
// 创建模拟的action对象
|
||||
$action = new stdClass();
|
||||
$action->extra = $storyIds;
|
||||
|
||||
$this->objectTao->processCreateRequirementsActionExtra($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processAppendLinkByExtra method.
|
||||
*
|
||||
* @param string $extra
|
||||
* @param string $objectType
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processAppendLinkByExtraTest(string $extra, string $objectType = 'task'): object
|
||||
{
|
||||
$action = new stdClass();
|
||||
$action->extra = $extra;
|
||||
$action->objectType = $objectType;
|
||||
|
||||
$this->objectTao->processAppendLinkByExtra($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processLinkStoryAndBugActionExtra method.
|
||||
*
|
||||
* @param string $extra
|
||||
* @param string $module
|
||||
* @param string $method
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processLinkStoryAndBugActionExtraTest(string $extra, string $module, string $method): object
|
||||
{
|
||||
$action = new stdClass();
|
||||
$action->extra = $extra;
|
||||
|
||||
$this->objectTao->processLinkStoryAndBugActionExtra($action, $module, $method);
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processToStoryActionExtra method.
|
||||
*
|
||||
* @param object $action
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processToStoryActionExtraTest(object $action): object
|
||||
{
|
||||
$this->objectTao->processToStoryActionExtra($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getActionTable method.
|
||||
*
|
||||
* @param string $period
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getActionTableTest(string $period): string
|
||||
{
|
||||
$result = $this->objectTao->getActionTable($period);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test addObjectNameForAction method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @param array $objectNames
|
||||
* @param string $actionType
|
||||
* @param string $extra
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function addObjectNameForActionTest(string $objectType, int $objectID, array $objectNames, string $actionType = '', string $extra = ''): object
|
||||
{
|
||||
// 创建测试用的action对象
|
||||
$action = new stdClass();
|
||||
$action->objectType = $objectType;
|
||||
$action->objectID = $objectID;
|
||||
$action->action = $actionType;
|
||||
$action->extra = $extra;
|
||||
$action->objectName = '';
|
||||
|
||||
$this->objectTao->addObjectNameForAction($action, $objectNames, $objectType);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processMaxDocObjectLink method.
|
||||
*
|
||||
* @param object $action
|
||||
* @param string $moduleName
|
||||
* @param string $methodName
|
||||
* @param string $vars
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processMaxDocObjectLinkTest(object $action, string $moduleName, string $methodName, string $vars): object
|
||||
{
|
||||
$this->objectTao->processMaxDocObjectLink($action, $moduleName, $methodName, $vars);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getDocLibLinkParameters method.
|
||||
*
|
||||
* @param object $action
|
||||
* @access public
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getDocLibLinkParametersTest(object $action)
|
||||
{
|
||||
$result = $this->objectTao->getDocLibLinkParameters($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getDoclibTypeParams method.
|
||||
*
|
||||
* @param object $action
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getDoclibTypeParamsTest(object $action): array
|
||||
{
|
||||
$result = $this->objectTao->getDoclibTypeParams($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getObjectLinkParams method.
|
||||
*
|
||||
* @param object $action
|
||||
* @param string $vars
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getObjectLinkParamsTest(object $action, string $vars): string
|
||||
{
|
||||
$result = $this->objectTao->getObjectLinkParams($action, $vars);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getReleaseRelated method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getReleaseRelated(string $objectType, int $objectID): array
|
||||
{
|
||||
$result = $this->objectTao->getReleaseRelated($objectType, $objectID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getReviewRelated method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getReviewRelatedTest(string $objectType, int $objectID): array
|
||||
{
|
||||
$result = $this->objectTao->getReviewRelated($objectType, $objectID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getNeedRelatedFields method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @param string $actionType
|
||||
* @param string $extra
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getNeedRelatedFieldsTest(string $objectType, int $objectID, string $actionType = '', string $extra = ''): array
|
||||
{
|
||||
$result = $this->objectTao->getNeedRelatedFields($objectType, $objectID, $actionType, $extra);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getGenerateRelated method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getGenerateRelatedTest(string $objectType, int $objectID): array
|
||||
{
|
||||
$result = $this->objectTao->getGenerateRelated($objectType, $objectID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getTaskRelated method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getTaskRelated(string $objectType, int $objectID): array
|
||||
{
|
||||
$result = $this->objectTao->getTaskRelated($objectType, $objectID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型和ID获取操作记录列表。
|
||||
* Get action list by type and ID.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int|array $objectID
|
||||
* @param array $modules
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getActionListByTypeAndIDTest(string $objectType, int|array $objectID, array $modules): array
|
||||
{
|
||||
$result = $this->objectTao->getActionListByTypeAndID($objectType, $objectID, $modules);
|
||||
$result = $this->invokeArgs('checkActionCanUndelete', [$action, $object]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -62,4 +62,393 @@ class actionTaoTest extends baseTest
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processAttribute method.
|
||||
*
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function processAttributeTest(string $type): string
|
||||
{
|
||||
$result = $this->instance->processAttribute($type);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getLinkedExtra method.
|
||||
*
|
||||
* @param object $action
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function getLinkedExtraTest(object $action, string $type): bool
|
||||
{
|
||||
$result = $this->instance->getLinkedExtra($action, $type);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processActionExtra method.
|
||||
*
|
||||
* @param string $table
|
||||
* @param int $extraID
|
||||
* @param string $fields
|
||||
* @param string $type
|
||||
* @param string $method
|
||||
* @param bool $onlyBody
|
||||
* @param bool $addLink
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function processActionExtraTest(string $table, int $extraID, string $fields, string $type, string $method = 'view', bool $onlyBody = false, bool $addLink = true): string
|
||||
{
|
||||
// 创建测试用的action对象
|
||||
$action = new stdClass();
|
||||
$action->extra = $extraID;
|
||||
$action->objectType = 'bug';
|
||||
$action->action = 'converttotask';
|
||||
$action->project = 1;
|
||||
|
||||
$originalExtra = $action->extra; // 备份原始extra值
|
||||
|
||||
// 模拟onlyBody场景
|
||||
if($onlyBody)
|
||||
{
|
||||
$originalIsonlybody = $this->instance->config->requestType ?? 'GET';
|
||||
$_GET['onlybody'] = 'yes';
|
||||
}
|
||||
|
||||
$this->instance->processActionExtra($table, $action, $fields, $type, $method, $onlyBody, $addLink);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
if($onlyBody) unset($_GET['onlybody']); // 恢复onlyBody状态
|
||||
|
||||
// 分析结果 - 优先检查特殊场景
|
||||
if($action->extra == $originalExtra) return 'no_change';
|
||||
if($onlyBody && strpos($action->extra, '<a') === false) return 'onlybody_mode';
|
||||
if(!$addLink && strpos($action->extra, '#') !== false && strpos($action->extra, '<a') === false) return 'no_link';
|
||||
if($action->objectType == 'bug' && $type == 'task' && strpos($action->extra, 'data-app=') !== false) return 'bug_to_task';
|
||||
if(strpos($action->extra, '<a') !== false) return 'contains_link';
|
||||
return 'processed';
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processStoryGradeActionExtra method.
|
||||
*
|
||||
* @param int $storyID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processStoryGradeActionExtraTest(int $storyID): object
|
||||
{
|
||||
// 创建测试用的action对象
|
||||
$action = new stdClass();
|
||||
$action->objectID = $storyID;
|
||||
$action->extra = '';
|
||||
|
||||
$result = $this->instance->processStoryGradeActionExtra($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processParamString method.
|
||||
*
|
||||
* @param object $action
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function processParamStringTest(object $action, string $type): string
|
||||
{
|
||||
$result = $this->instance->processParamString($action, $type);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processCreateChildrenActionExtra method.
|
||||
*
|
||||
* @param string $taskIds
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processCreateChildrenActionExtraTest(string $taskIds): object
|
||||
{
|
||||
// 创建模拟的action对象
|
||||
$action = new stdClass();
|
||||
$action->extra = $taskIds;
|
||||
|
||||
$this->instance->processCreateChildrenActionExtra($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processCreateRequirementsActionExtra method.
|
||||
*
|
||||
* @param string $storyIds
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processCreateRequirementsActionExtraTest(string $storyIds): object
|
||||
{
|
||||
// 创建模拟的action对象
|
||||
$action = new stdClass();
|
||||
$action->extra = $storyIds;
|
||||
|
||||
$this->instance->processCreateRequirementsActionExtra($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processAppendLinkByExtra method.
|
||||
*
|
||||
* @param string $extra
|
||||
* @param string $objectType
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processAppendLinkByExtraTest(string $extra, string $objectType = 'task'): object
|
||||
{
|
||||
$action = new stdClass();
|
||||
$action->extra = $extra;
|
||||
$action->objectType = $objectType;
|
||||
|
||||
$this->instance->processAppendLinkByExtra($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processLinkStoryAndBugActionExtra method.
|
||||
*
|
||||
* @param string $extra
|
||||
* @param string $module
|
||||
* @param string $method
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processLinkStoryAndBugActionExtraTest(string $extra, string $module, string $method): object
|
||||
{
|
||||
$action = new stdClass();
|
||||
$action->extra = $extra;
|
||||
|
||||
$this->instance->processLinkStoryAndBugActionExtra($action, $module, $method);
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processToStoryActionExtra method.
|
||||
*
|
||||
* @param object $action
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processToStoryActionExtraTest(object $action): object
|
||||
{
|
||||
$this->instance->processToStoryActionExtra($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getActionTable method.
|
||||
*
|
||||
* @param string $period
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getActionTableTest(string $period): string
|
||||
{
|
||||
$result = $this->instance->getActionTable($period);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test addObjectNameForAction method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @param array $objectNames
|
||||
* @param string $actionType
|
||||
* @param string $extra
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function addObjectNameForActionTest(string $objectType, int $objectID, array $objectNames, string $actionType = '', string $extra = ''): object
|
||||
{
|
||||
// 创建测试用的action对象
|
||||
$action = new stdClass();
|
||||
$action->objectType = $objectType;
|
||||
$action->objectID = $objectID;
|
||||
$action->action = $actionType;
|
||||
$action->extra = $extra;
|
||||
$action->objectName = '';
|
||||
|
||||
$this->instance->addObjectNameForAction($action, $objectNames, $objectType);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processMaxDocObjectLink method.
|
||||
*
|
||||
* @param object $action
|
||||
* @param string $moduleName
|
||||
* @param string $methodName
|
||||
* @param string $vars
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function processMaxDocObjectLinkTest(object $action, string $moduleName, string $methodName, string $vars): object
|
||||
{
|
||||
$this->instance->processMaxDocObjectLink($action, $moduleName, $methodName, $vars);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getDocLibLinkParameters method.
|
||||
*
|
||||
* @param object $action
|
||||
* @access public
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getDocLibLinkParametersTest(object $action)
|
||||
{
|
||||
$result = $this->instance->getDocLibLinkParameters($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getDoclibTypeParams method.
|
||||
*
|
||||
* @param object $action
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getDoclibTypeParamsTest(object $action): array
|
||||
{
|
||||
$result = $this->instance->getDoclibTypeParams($action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getObjectLinkParams method.
|
||||
*
|
||||
* @param object $action
|
||||
* @param string $vars
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getObjectLinkParamsTest(object $action, string $vars): string
|
||||
{
|
||||
$result = $this->instance->getObjectLinkParams($action, $vars);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getReleaseRelated method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getReleaseRelated(string $objectType, int $objectID): array
|
||||
{
|
||||
$result = $this->instance->getReleaseRelated($objectType, $objectID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getReviewRelated method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getReviewRelatedTest(string $objectType, int $objectID): array
|
||||
{
|
||||
$result = $this->instance->getReviewRelated($objectType, $objectID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getNeedRelatedFields method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @param string $actionType
|
||||
* @param string $extra
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getNeedRelatedFieldsTest(string $objectType, int $objectID, string $actionType = '', string $extra = ''): array
|
||||
{
|
||||
$result = $this->instance->getNeedRelatedFields($objectType, $objectID, $actionType, $extra);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getGenerateRelated method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getGenerateRelatedTest(string $objectType, int $objectID): array
|
||||
{
|
||||
$result = $this->instance->getGenerateRelated($objectType, $objectID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getTaskRelated method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getTaskRelated(string $objectType, int $objectID): array
|
||||
{
|
||||
$result = $this->instance->getTaskRelated($objectType, $objectID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型和ID获取操作记录列表。
|
||||
* Get action list by type and ID.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int|array $objectID
|
||||
* @param array $modules
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getActionListByTypeAndIDTest(string $objectType, int|array $objectID, array $modules): array
|
||||
{
|
||||
$result = $this->instance->getActionListByTypeAndID($objectType, $objectID, $modules);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,12 +182,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function getDefaultLanguageModelTest()
|
||||
{
|
||||
// 使用反射来测试私有方法
|
||||
$method = new ReflectionMethod($this->instance, 'getDefaultLanguageModel');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke($this->instance);
|
||||
$result = $this->invokeArgs('getDefaultLanguageModel');
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -200,13 +196,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function serializeModelTest($model = null)
|
||||
{
|
||||
/* Using reflection to call private method */
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('serializeModel');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke($this->instance, $model);
|
||||
$result = $this->invokeArgs('serializeModel', [$model]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -221,7 +212,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->unserializeModel($model);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -236,7 +226,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->createModel($model);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -405,13 +394,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function getProxyTypeTest($proxyType = null)
|
||||
{
|
||||
/* Using reflection to call private static method */
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('getProxyType');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke(null, $proxyType);
|
||||
$result = $this->invokeArgs('getProxyType', [$proxyType]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -424,13 +408,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function camelCaseToSnakeCaseTest($str = null)
|
||||
{
|
||||
/* Using reflection to call private static method */
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('camelCaseToSnakeCase');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke(null, $str);
|
||||
$result = $this->invokeArgs('camelCaseToSnakeCase', [$str]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -443,13 +422,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function standardizeParamsTest($data = null)
|
||||
{
|
||||
/* Using reflection to call private static method */
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('standardizeParams');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke(null, $data);
|
||||
$result = $this->invokeArgs(i'standardizeParams', [$data]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -463,13 +437,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function assembleRequestDataTest($type = null, $data = null)
|
||||
{
|
||||
/* Using reflection to call private method */
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('assembleRequestData');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke($this->instance, $type, $data);
|
||||
$result = $this->invokeArgs('assembleRequestData', [$type, $data]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -482,13 +451,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function decodeResponseTest($response = null)
|
||||
{
|
||||
/* Using reflection to call private method */
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('decodeResponse');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke($this->instance, $response);
|
||||
$result = $this->invokeArgs('decodeResponse', [$response]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -501,13 +465,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function parseTextResponseTest($response = null)
|
||||
{
|
||||
/* Using reflection to call private method */
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('parseTextResponse');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke($this->instance, $response);
|
||||
$result = $this->invokeArgs('parseTextResponse', [$response]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -520,13 +479,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function parseChatResponseTest($response = null)
|
||||
{
|
||||
/* Using reflection to call private method */
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('parseChatResponse');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke($this->instance, $response);
|
||||
$result = $this->invokeArgs('parseChatResponse', [$response]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -539,13 +493,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function parseFunctionCallResponseTest($response = null)
|
||||
{
|
||||
/* Using reflection to call private method */
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('parseFunctionCallResponse');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke($this->instance, $response);
|
||||
$result = $this->invokeArgs('parseFunctionCallResponse', [$response]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -656,7 +605,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->converse($model, $messages, $options);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -846,7 +794,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->countLatestMiniPrograms();
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -863,7 +810,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->saveMiniProgramMessage($appID, $type, $content);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -880,7 +826,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->deleteHistoryMessagesByID($appID, $userID, $messageIDs);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -896,7 +841,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getHistoryMessages($appID, $limit);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1057,7 +1001,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getMiniProgramByID($id);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1071,7 +1014,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getCustomCategories();
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1085,7 +1027,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getUsedCustomCategories();
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1099,7 +1040,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getPublishedCustomCategories();
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1115,7 +1055,6 @@ class aiModelTest extends baseTest
|
||||
$_POST = $postData;
|
||||
$result = $this->instance->checkDuplicatedCategory();
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1133,7 +1072,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getMiniPrograms($category, $status, $order, $pager);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1148,7 +1086,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getMiniProgramFields($appID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1203,7 +1140,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->publishMiniProgram($appID, $published);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1220,7 +1156,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->collectMiniProgram($userID, $appID, $delete);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1235,7 +1170,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->canPublishMiniProgram($program);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1250,7 +1184,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->createMiniProgram($data);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1330,7 +1263,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->checkDuplicatedAppName($name, $appID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result ? '1' : '0';
|
||||
}
|
||||
|
||||
@@ -1345,7 +1277,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getUniqueAppName($name);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1362,7 +1293,6 @@ class aiModelTest extends baseTest
|
||||
$_POST = $postData;
|
||||
$result = $this->instance->verifyRequiredFields($requiredFields);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1380,7 +1310,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getPrompts($module, $status, $order, $pager);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1395,7 +1324,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getPromptById($id);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1410,7 +1338,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getPromptFields($promptID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1425,7 +1352,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->createPrompt($prompt);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1442,12 +1368,11 @@ class aiModelTest extends baseTest
|
||||
$this->instance->savePromptFields($promptID, $data);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
$fields = $this->instance->dao->select('*')
|
||||
$count = $this->instance->dao->select('COUNT(1) AS count')
|
||||
->from(TABLE_AI_PROMPTFIELD)
|
||||
->where('appID')->eq($promptID)
|
||||
->fetchAll();
|
||||
|
||||
return count($fields);
|
||||
->fetch('count');
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1462,7 +1387,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->updatePrompt($prompt, $originalPrompt);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1477,7 +1401,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->deletePrompt($id);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1493,7 +1416,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->togglePromptStatus($prompt, $status);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1691,13 +1613,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function isAssocTest($array = null)
|
||||
{
|
||||
/* Using reflection to call private static method */
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('isAssoc');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke(null, $array);
|
||||
$result = $this->invokeArgs('isAssoc', [$array]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1800,13 +1717,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function autoPrependNewlineTest($text = '')
|
||||
{
|
||||
$reflectionClass = new ReflectionClass('aiModel');
|
||||
$method = $reflectionClass->getMethod('autoPrependNewline');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke(null, $text);
|
||||
$result = $this->invokeArgs('autoPrependNewline', [$text]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1820,13 +1732,8 @@ class aiModelTest extends baseTest
|
||||
*/
|
||||
public function tryPunctuateTest($sentence = '', $newline = false)
|
||||
{
|
||||
$reflectionClass = new ReflectionClass('aiModel');
|
||||
$method = $reflectionClass->getMethod('tryPunctuate');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke(null, $sentence, $newline);
|
||||
$result = $this->invokeArgs('tryPunctuate', [$sentence, $newline]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1842,7 +1749,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = aiModel::assemblePrompt($prompt, $dataPrompt);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1857,7 +1763,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->isExecutable($prompt);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2140,7 +2045,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->tryGetRelatedObjects($prompt, $object, $objectNames);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2155,7 +2059,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getLastActiveStep($prompt);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2217,7 +2120,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->filterPromptsForExecution($prompts, $keepUnauthorized);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2233,7 +2135,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$this->instance->setInjectData($form, $data);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return '0';
|
||||
}
|
||||
|
||||
@@ -2247,7 +2148,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getRoleTemplates();
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2263,7 +2163,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->createRoleTemplate($role, $characterization);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2278,7 +2177,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->deleteRoleTemplate($id);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2295,7 +2193,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->updateRoleTemplate($id, $role, $characterization);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2311,7 +2208,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getAssistants($pager, $orderBy);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2387,7 +2283,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getAssistantById($assistantId);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2403,7 +2298,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->createAssistant($assistant, $publish);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2418,7 +2312,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->updateAssistant($assistant);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2434,7 +2327,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->toggleAssistant($assistantId, $enabled);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2450,7 +2342,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->checkAssistantDuplicate($assistantName, $modelId);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -2467,7 +2358,6 @@ class aiModelTest extends baseTest
|
||||
|
||||
$result = $this->instance->deleteAssistant($assistantId);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result ? '1' : '0';
|
||||
}
|
||||
|
||||
@@ -2482,7 +2372,6 @@ class aiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getTestPromptData($prompt);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return !empty($result[1]) ? '1' : '0';
|
||||
}
|
||||
|
||||
|
||||
@@ -8,20 +8,6 @@ class aiappModelTest extends baseTest
|
||||
protected $moduleName = 'aiapp';
|
||||
protected $className = 'model';
|
||||
|
||||
/**
|
||||
* Test __construct method.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function __constructTest()
|
||||
{
|
||||
$result = $this->instance;
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getLatestMiniPrograms method.
|
||||
*
|
||||
@@ -34,7 +20,6 @@ class aiappModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getLatestMiniPrograms($pager, $order);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -46,12 +31,8 @@ class aiappModelTest extends baseTest
|
||||
*/
|
||||
public function countLatestMiniProgramsTest()
|
||||
{
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('countLatestMiniPrograms');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invoke($this->instance);
|
||||
$result = $this->invokeArgs('countLatestMiniPrograms');
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -68,7 +49,6 @@ class aiappModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->saveMiniProgramMessage($appID, $type, $content);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -83,12 +63,8 @@ class aiappModelTest extends baseTest
|
||||
*/
|
||||
public function deleteHistoryMessagesByIDTest($appID, $userID, $messageIDs)
|
||||
{
|
||||
$reflection = new ReflectionClass($this->instance);
|
||||
$method = $reflection->getMethod('deleteHistoryMessagesByID');
|
||||
$method->setAccessible(true);
|
||||
$method->invoke($this->instance, $appID, $userID, $messageIDs);
|
||||
$this->invokeArgs('deleteHistoryMessagesByID', [$appID, $userID, $messageIDs]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -104,7 +80,6 @@ class aiappModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getHistoryMessages($appID, $limit);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -120,7 +95,6 @@ class aiappModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getCollectedMiniProgramIDs($userID, $pager);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -136,7 +110,6 @@ class aiappModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getSquareCategoryArray($collectedIDs, $latestSum);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -150,7 +123,6 @@ class aiappModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getUsedCategoryArray();
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ class apiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->publishLib($data);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -846,7 +845,6 @@ class apiModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getPrivApis($mode);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,563 +8,6 @@ class apiZenTest extends baseTest
|
||||
protected $moduleName = 'api';
|
||||
protected $className = 'zen';
|
||||
|
||||
/**
|
||||
* Test publish a lib.
|
||||
*
|
||||
* @param object $data
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function publishLibTest($data)
|
||||
{
|
||||
$result = $this->objectModel->publishLib($data);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete a release.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $libID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function deleteReleaseTest($id, $libID = 0)
|
||||
{
|
||||
$this->objectModel->deleteRelease($id);
|
||||
|
||||
$objects = $this->objectModel->getRelease($libID);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getApiStatusText method.
|
||||
*
|
||||
* @param string $status
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getApiStatusTextTest($status)
|
||||
{
|
||||
$result = $this->objectModel->getApiStatusText($status);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create a api.
|
||||
*
|
||||
* @param array $params
|
||||
* @param bool $confirm
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function createTest($params, $confirm = true)
|
||||
{
|
||||
global $tester;
|
||||
|
||||
$_POST = $params;
|
||||
$objects = $this->objectModel->create($params['lib']);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
if($confirm) $tester->dao->delete()->from(TABLE_API)->where('id')->eq($objects->id)->exec();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create a data struct.
|
||||
*
|
||||
* @param object $data
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function createStructTest($data)
|
||||
{
|
||||
$result = $this->objectModel->createStruct($data);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update a data struct.
|
||||
*
|
||||
* @param object $formData
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function updateStructTest($formData)
|
||||
{
|
||||
$result = $this->objectModel->updateStruct($formData);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update a api.
|
||||
*
|
||||
* @param int $apiID
|
||||
* @param array $params
|
||||
* @param bool $confirm
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function updateTest($apiID, $params, $confirm = true)
|
||||
{
|
||||
global $tester;
|
||||
$_POST = $params;
|
||||
|
||||
$objects = $this->objectModel->update($apiID);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
if($confirm) $tester->dao->delete()->from(TABLE_API)->where('id')->eq($apiID)->exec();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get data struct list by libID.
|
||||
*
|
||||
* @param int $id
|
||||
* @param bool $confirm
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getStructListByLibIDTest($id, $confirm = true)
|
||||
{
|
||||
global $tester;
|
||||
|
||||
$objects = $this->objectModel->getStructListByLibID($id);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
if($confirm) $tester->dao->delete()->from(TABLE_APISTRUCT)->where('id')->eq($objects['0']->id)->exec();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get a data struct by ID.
|
||||
*
|
||||
* @param int $id
|
||||
* @param bool $confirm
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getStructByIDTest($id, $confirm = true)
|
||||
{
|
||||
global $tester;
|
||||
|
||||
$objects = $this->objectModel->getStructByID($id);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
if($confirm) $tester->dao->delete()->from(TABLE_APISTRUCT)->where('id')->eq($objects->id)->exec();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get release by libID.
|
||||
*
|
||||
* @param int $libID
|
||||
* @param string $type
|
||||
* @param int $params
|
||||
* @param bool $confirm
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getReleaseTest($libID = 0, $type = '', $param = 0, $confirm = true)
|
||||
{
|
||||
$objects = $this->objectModel->getRelease($libID = 0, $type = '', $param = 0);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
if($confirm) $this->objectModel->deleteRelease($objects->id);
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get release list by api.
|
||||
*
|
||||
* @param int $libID
|
||||
* @param int $id
|
||||
* @param bool $confirm
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getReleaseListByApiTest($libID, $id = 0, $confirm = true)
|
||||
{
|
||||
$objects = $this->objectModel->getReleaseListByApi($libID);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
if($confirm) $this->objectModel->deleteRelease($objects[$id]->id);
|
||||
|
||||
return $objects[$id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get lib by ID.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $version
|
||||
* @param int $release
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getLibByIdTest($id, $version = 0, $release = 0)
|
||||
{
|
||||
$objects = $this->objectModel->getLibById($id, $version = 0, $release = 0);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get lib by ID.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $version
|
||||
* @param int $release
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getApiListByReleaseTest($release, $where = '1 = 1 ')
|
||||
{
|
||||
global $tester;
|
||||
|
||||
$objects = $this->objectModel->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();
|
||||
$this->objectModel->deleteRelease($release->id);
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list by module ID.
|
||||
*
|
||||
* @param int $libID
|
||||
* @param int $moduleID
|
||||
* @param int $release
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getListByModuleIdTest($libID = 0, $moduleID = 0, $release = 0)
|
||||
{
|
||||
$objects = $this->objectModel->getListByModuleId($libID, $moduleID, $release);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return current($objects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get struct list by release.
|
||||
*
|
||||
* @param object $release
|
||||
* @param string $where
|
||||
* @param string $orderBy
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getStructListByReleaseTest($release, $where = '1 = 1 ', $orderBy = 'id')
|
||||
{
|
||||
$objects = $this->objectModel->getStructListByRelease($release, $where = '1 = 1 ', $orderBy = 'id');
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test createDemoLib method.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $baseUrl
|
||||
* @param string $currentAccount
|
||||
* @access public
|
||||
* @return object|false
|
||||
*/
|
||||
public function createDemoLibTest($name, $baseUrl, $currentAccount)
|
||||
{
|
||||
global $tester;
|
||||
|
||||
$reflection = new ReflectionClass($this->objectModel);
|
||||
$method = $reflection->getMethod('createDemoLib');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$libID = $method->invoke($this->objectModel, $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();
|
||||
|
||||
return $lib;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test createDemoStruct method.
|
||||
*
|
||||
* @param int $libID
|
||||
* @param string $version
|
||||
* @param string $currentAccount
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function createDemoStructTest($libID, $version, $currentAccount)
|
||||
{
|
||||
global $tester;
|
||||
|
||||
$reflection = new ReflectionClass($this->objectModel);
|
||||
$method = $reflection->getMethod('createDemoStruct');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->objectModel, $libID, $version, $currentAccount);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test createDemoStructSpec method.
|
||||
*
|
||||
* @param string $version
|
||||
* @param string $currentAccount
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function createDemoStructSpecTest($version, $currentAccount)
|
||||
{
|
||||
global $tester;
|
||||
|
||||
$reflection = new ReflectionClass($this->objectModel);
|
||||
$method = $reflection->getMethod('createDemoStructSpec');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->objectModel, $version, $currentAccount);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test createDemoModule method.
|
||||
*
|
||||
* @param int $libID
|
||||
* @param string $version
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function createDemoModuleTest($libID, $version)
|
||||
{
|
||||
global $tester;
|
||||
|
||||
$reflection = new ReflectionClass($this->objectModel);
|
||||
$method = $reflection->getMethod('createDemoModule');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->objectModel, $libID, $version);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test createDemoApi method.
|
||||
*
|
||||
* @param int $libID
|
||||
* @param string $version
|
||||
* @param array $moduleMap
|
||||
* @param string $currentAccount
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function createDemoApiTest($libID, $version, $moduleMap, $currentAccount)
|
||||
{
|
||||
global $tester;
|
||||
|
||||
$reflection = new ReflectionClass($this->objectModel);
|
||||
$method = $reflection->getMethod('createDemoApi');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->objectModel, $libID, $version, $moduleMap, $currentAccount);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test createDemoApiSpec method.
|
||||
*
|
||||
* @param string $version
|
||||
* @param array $apiMap
|
||||
* @param array $moduleMap
|
||||
* @param string $currentAccount
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function createDemoApiSpecTest($version, $apiMap, $moduleMap, $currentAccount)
|
||||
{
|
||||
global $tester;
|
||||
|
||||
try
|
||||
{
|
||||
// 先检查版本文件是否存在,避免后续的file_get_contents错误
|
||||
$demoDataFile = $this->objectModel->app->getAppRoot() . 'db' . DS . 'api' . DS . $version . DS . 'apispec';
|
||||
if (!file_exists($demoDataFile)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$reflection = new ReflectionClass($this->objectModel);
|
||||
$method = $reflection->getMethod('createDemoApiSpec');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->objectModel, $version, $apiMap, $moduleMap, $currentAccount);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result ? 1 : 0;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
catch(TypeError $e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getGroupedObjects method.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupedObjectsTest()
|
||||
{
|
||||
$result = $this->objectModel->getGroupedObjects();
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test buildSearchForm method.
|
||||
*
|
||||
* @param object $lib
|
||||
* @param int $queryID
|
||||
* @param string $actionURL
|
||||
* @param array $libs
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function buildSearchFormTest($lib, $queryID, $actionURL, $libs = array(), $type = '')
|
||||
{
|
||||
global $tester;
|
||||
|
||||
// 备份原始配置
|
||||
$originalConfig = isset($tester->config->api->search) ? $tester->config->api->search : null;
|
||||
|
||||
// 执行方法
|
||||
$this->objectModel->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()
|
||||
);
|
||||
|
||||
// 恢复原始配置
|
||||
if($originalConfig !== null) $tester->config->api->search = $originalConfig;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getApiSpecByData method.
|
||||
*
|
||||
* @param object $data
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getApiSpecByDataTest($data)
|
||||
{
|
||||
$reflection = new ReflectionClass($this->objectModel);
|
||||
$method = $reflection->getMethod('getApiSpecByData');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->objectModel, $data);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getApiStructSpecByData method.
|
||||
*
|
||||
* @param object $data
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getApiStructSpecByDataTest($data)
|
||||
{
|
||||
$reflection = new ReflectionClass($this->objectModel);
|
||||
$method = $reflection->getMethod('getApiStructSpecByData');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->objectModel, $data);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getTypeList method.
|
||||
*
|
||||
* @param int $libID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getTypeListTest($libID)
|
||||
{
|
||||
$result = $this->objectModel->getTypeList($libID);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test generateLibsDropMenu method.
|
||||
*
|
||||
@@ -575,31 +18,8 @@ class apiZenTest extends baseTest
|
||||
*/
|
||||
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);
|
||||
|
||||
$result = $this->invokeArgs('generateLibsDropMenu', [$lib, $version]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -613,112 +33,14 @@ class apiZenTest extends baseTest
|
||||
* @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 = '')
|
||||
public function parseDocSpaceParamTest(array $libs, int $libID, string $type, int $objectID, int $moduleID, string $spaceType, int $release)
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
$this->invokeArgs('parseDocSpaceParam', [$libs, $libID, $type, $objectID, $moduleID, $spaceType, $release]);
|
||||
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)
|
||||
);
|
||||
return $this->getProperty('view');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -731,36 +53,9 @@ class apiZenTest extends baseTest
|
||||
*/
|
||||
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());
|
||||
}
|
||||
$result = $this->invokeArgs('getMethod', [$filePath, $ext]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -773,80 +68,10 @@ class apiZenTest extends baseTest
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function requestTest(string $moduleName, string $methodName, string $action, array $postData = array())
|
||||
public function requestTest(string $moduleName, string $methodName, string $action)
|
||||
{
|
||||
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¶ms=$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;
|
||||
|
||||
$result = $this->invokeArgs('request', [$moduleName, $methodName, $action]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return array('url' => $url, 'content' => $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getPrivApis method.
|
||||
*
|
||||
* @param string $mode
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getPrivApisTest($mode = '')
|
||||
{
|
||||
$result = $this->objectModel->getPrivApis($mode);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ class backupModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->backSQL($backupFile);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -34,7 +33,6 @@ class backupModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->backFile($backupFile);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -49,7 +47,6 @@ class backupModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->backCode($backupFile);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -97,7 +94,6 @@ class backupModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->restoreFile($backupFile);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -112,7 +108,6 @@ class backupModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getDiskSpace($backupPath);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -130,7 +125,6 @@ class backupModelTest extends baseTest
|
||||
|
||||
$result = $this->instance->getDirSize($dir);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -239,271 +233,6 @@ class backupModelTest extends baseTest
|
||||
return array('result' => 'success');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test backupCode method for zen layer.
|
||||
*
|
||||
* @param string $fileName
|
||||
* @param string $reload
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function backupCodeZenTest($fileName = null, $reload = 'no')
|
||||
{
|
||||
global $tester;
|
||||
$objectTao = $tester->loadTao('backup');
|
||||
|
||||
// Mock implementation to simulate backupCode behavior
|
||||
if(empty($fileName))
|
||||
{
|
||||
$fileName = 'test_backup_code_' . time();
|
||||
}
|
||||
|
||||
// Mock different scenarios based on input
|
||||
if($fileName === 'fail_test')
|
||||
{
|
||||
if($reload === 'yes')
|
||||
{
|
||||
return array('result' => 'fail', 'message' => 'Mock code backup failed');
|
||||
}
|
||||
else
|
||||
{
|
||||
return array('result' => 'fail', 'message' => 'Mock code backup failed');
|
||||
}
|
||||
}
|
||||
|
||||
// Mock nofile setting check - if nofile is in config, skip code backup
|
||||
if(isset($this->instance->config->backup->setting) && str_contains($this->instance->config->backup->setting, 'nofile'))
|
||||
{
|
||||
return array('result' => 'success');
|
||||
}
|
||||
|
||||
// Mock backCode method call result
|
||||
$mockResult = new stdClass();
|
||||
$mockResult->result = true;
|
||||
$mockResult->error = '';
|
||||
|
||||
// Simulate failure scenario for specific test cases
|
||||
if($fileName === 'invalid_path')
|
||||
{
|
||||
$mockResult->result = false;
|
||||
$mockResult->error = 'Invalid backup path';
|
||||
return array('result' => 'fail', 'message' => sprintf('备份代码失败: %s', $mockResult->error));
|
||||
}
|
||||
|
||||
// Return success for normal cases
|
||||
return array('result' => 'success');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test removeExpiredFiles method for zen layer.
|
||||
*
|
||||
* @param array $mockFiles
|
||||
* @param int $mockHoldDays
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function removeExpiredFilesTest($mockFiles = null, $mockHoldDays = 14)
|
||||
{
|
||||
global $tester;
|
||||
|
||||
// Mock backup path
|
||||
$mockBackupPath = sys_get_temp_dir() . '/backup_test_' . time() . '/';
|
||||
if(!is_dir($mockBackupPath)) mkdir($mockBackupPath, 0777, true);
|
||||
|
||||
// Create mock backup files with different ages
|
||||
if($mockFiles === null)
|
||||
{
|
||||
$mockFiles = array(
|
||||
'20240101.sql' => time() - (20 * 24 * 3600), // 20 days ago - expired
|
||||
'20240110.file' => time() - (10 * 24 * 3600), // 10 days ago - not expired
|
||||
'20240115.code' => time() - (5 * 24 * 3600), // 5 days ago - not expired
|
||||
'20240120.sql' => time() - (30 * 24 * 3600), // 30 days ago - expired
|
||||
'other.txt' => time() - (10 * 24 * 3600), // non-backup file - should be ignored
|
||||
);
|
||||
}
|
||||
|
||||
// Only create files if mockFiles is not empty
|
||||
if(!empty($mockFiles))
|
||||
{
|
||||
foreach($mockFiles as $fileName => $fileTime)
|
||||
{
|
||||
$filePath = $mockBackupPath . $fileName;
|
||||
touch($filePath, $fileTime);
|
||||
}
|
||||
}
|
||||
|
||||
// Mock zen object behavior
|
||||
$mockZen = new stdClass();
|
||||
$mockZen->backupPath = $mockBackupPath;
|
||||
$mockZen->config = new stdClass();
|
||||
$mockZen->config->backup = new stdClass();
|
||||
$mockZen->config->backup->holdDays = $mockHoldDays;
|
||||
|
||||
// Simulate removeExpiredFiles method logic
|
||||
$backupFiles = glob("{$mockZen->backupPath}*.*");
|
||||
if(empty($backupFiles))
|
||||
{
|
||||
$this->cleanupTestDir($mockBackupPath);
|
||||
return array('removed' => 0, 'kept' => 0);
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$removed = 0;
|
||||
$kept = 0;
|
||||
|
||||
foreach($backupFiles as $file)
|
||||
{
|
||||
$fileName = basename($file);
|
||||
if(!preg_match('/[0-9]+\.(sql|file|code)/', $fileName))
|
||||
{
|
||||
// Non-backup files are ignored in the logic, not counted in kept
|
||||
continue;
|
||||
}
|
||||
|
||||
$fileAge = $time - filemtime($file);
|
||||
$holdSeconds = $mockZen->config->backup->holdDays * 24 * 3600;
|
||||
|
||||
if($fileAge > $holdSeconds)
|
||||
{
|
||||
unlink($file); // Remove expired file
|
||||
$removed++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$kept++; // Keep non-expired file
|
||||
}
|
||||
}
|
||||
|
||||
$this->cleanupTestDir($mockBackupPath);
|
||||
return array('removed' => $removed, 'kept' => $kept);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test restoreSQL method for zen layer.
|
||||
*
|
||||
* @param string $fileName
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function restoreSQLZenTest($fileName = null)
|
||||
{
|
||||
global $tester;
|
||||
$objectTao = $tester->loadTao('backup');
|
||||
|
||||
// Mock implementation to simulate restoreSQL behavior
|
||||
if(empty($fileName))
|
||||
{
|
||||
return array('result' => 'success');
|
||||
}
|
||||
|
||||
// Mock different scenarios based on fileName - these should fail
|
||||
if($fileName === 'nonexistent')
|
||||
{
|
||||
return array('result' => 'fail', 'message' => '数据库还原失败,错误:备份文件不存在');
|
||||
}
|
||||
|
||||
if($fileName === 'corrupted')
|
||||
{
|
||||
return array('result' => 'fail', 'message' => '数据库还原失败,错误:备份文件格式错误');
|
||||
}
|
||||
|
||||
if($fileName === 'permission_denied')
|
||||
{
|
||||
return array('result' => 'fail', 'message' => '数据库还原失败,错误:权限不足');
|
||||
}
|
||||
|
||||
if($fileName === 'invalid_format')
|
||||
{
|
||||
return array('result' => 'fail', 'message' => '数据库还原失败,错误:SQL文件格式无效');
|
||||
}
|
||||
|
||||
if($fileName === 'restore_fail_test')
|
||||
{
|
||||
return array('result' => 'fail', 'message' => '数据库还原失败,错误:Mock restoration failed');
|
||||
}
|
||||
|
||||
// For normal cases, first check if backup file exists using mock logic
|
||||
// Since we can't actually call getBackupFile without real backup files, mock this behavior
|
||||
|
||||
// Mock that test_backup has a corresponding backup file
|
||||
if($fileName === 'test_backup')
|
||||
{
|
||||
// Mock successful restoration
|
||||
return array('result' => 'success');
|
||||
}
|
||||
|
||||
// For other cases, mock as no backup file found (return success as per original zen method)
|
||||
return array('result' => 'success');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test restoreFile method for zen layer.
|
||||
*
|
||||
* @param string $fileName
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function restoreFileZenTest($fileName = null)
|
||||
{
|
||||
if(is_null($fileName)) return array('result' => 'fail', 'message' => '文件名不能为空');
|
||||
|
||||
if($fileName === 'invalid_format')
|
||||
{
|
||||
return array('result' => 'fail', 'message' => '附件还原失败,错误:文件格式无效');
|
||||
}
|
||||
|
||||
if($fileName === 'restore_fail_test')
|
||||
{
|
||||
return array('result' => 'fail', 'message' => '附件还原失败,错误:Mock restoration failed');
|
||||
}
|
||||
|
||||
// For normal cases, mock successful restoration
|
||||
if($fileName === 'test_backup')
|
||||
{
|
||||
return array('result' => 'success');
|
||||
}
|
||||
|
||||
// For other cases, mock as no backup file found (return success as per original zen method)
|
||||
return array('result' => 'success');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test setHoldDays method for zen layer.
|
||||
*
|
||||
* @param object $data
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function setHoldDaysTest($data = null)
|
||||
{
|
||||
// Mock implementation based on setHoldDays logic in zen.php
|
||||
if(is_null($data))
|
||||
{
|
||||
$data = new stdClass();
|
||||
$data->holdDays = 14;
|
||||
}
|
||||
|
||||
// Simulate dao::$errors reset
|
||||
dao::$errors = array();
|
||||
|
||||
// Check if holdDays is empty (but 0 is not considered empty in this context)
|
||||
if(empty($data->holdDays) && $data->holdDays !== 0)
|
||||
{
|
||||
dao::$errors['holdDays'] = '『保留天数』不能为空。';
|
||||
return dao::$errors;
|
||||
}
|
||||
|
||||
// Check if holdDays is a positive integer
|
||||
if(!preg_match("/^-?\d+$/", (string)$data->holdDays) || $data->holdDays <= 0)
|
||||
{
|
||||
dao::$errors['holdDays'] = '『保留天数』应当是正整数。';
|
||||
return dao::$errors;
|
||||
}
|
||||
|
||||
// Mock successful setting save
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test addFileHeader method.
|
||||
*
|
||||
@@ -515,7 +244,6 @@ class backupModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->addFileHeader($fileName);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -530,7 +258,6 @@ class backupModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getBackupDirProgress($backup);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -544,7 +271,6 @@ class backupModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getBackupPath();
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -559,7 +285,6 @@ class backupModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->getTmpLogFile($backupFile);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -574,7 +299,6 @@ class backupModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->processFileSize($fileSize);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -594,7 +318,6 @@ class backupModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->processSummary($file, $count, $size, $errorFiles, $allCount, $action);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -609,7 +332,6 @@ class backupModelTest extends baseTest
|
||||
{
|
||||
$result = $this->instance->removeFileHeader($fileName);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -631,4 +353,4 @@ class backupModelTest extends baseTest
|
||||
}
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+91
-2255
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,29 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 biModel::getTableFields();
|
||||
timeout=0
|
||||
cid=15185
|
||||
|
||||
- 测试正常调用返回结果是数组类型 @array
|
||||
- 测试返回结果不为空 @not_empty
|
||||
- 测试返回结果包含表名键 @has_tables
|
||||
- 测试每个表都包含字段信息 @has_fields
|
||||
- 测试字段信息结构完整性 @valid_structure
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/model.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$bi = new biModelTest();
|
||||
|
||||
r($bi->getTableFieldsTest()) && p() && e('array'); // 测试正常调用返回结果是数组类型
|
||||
r($bi->getTableFieldsTestNotEmpty()) && p() && e('not_empty'); // 测试返回结果不为空
|
||||
r($bi->getTableFieldsTestHasTables()) && p() && e('has_tables'); // 测试返回结果包含表名键
|
||||
r($bi->getTableFieldsTestHasFields()) && p() && e('has_fields'); // 测试每个表都包含字段信息
|
||||
r($bi->getTableFieldsTestValidStructure()) && p() && e('valid_structure'); // 测试字段信息结构完整性
|
||||
@@ -203,6 +203,7 @@ class baseTest
|
||||
$method = $reflection->getMethod($methodName);
|
||||
if(!$method->isPublic()) $method->setAccessible(true);
|
||||
|
||||
return $method->invokeArgs($instance, $args);
|
||||
$object = $method->isStatic() ? null : $instance;
|
||||
return $method->invokeArgs($object, $args);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user