diff --git a/test/class/action.class.php b/test/class/action.class.php new file mode 100644 index 0000000000..d85fe89400 --- /dev/null +++ b/test/class/action.class.php @@ -0,0 +1,482 @@ +objectModel = $tester->loadModel('action'); + $tester->dao->delete()->from(TABLE_ACTION)->where('action')->eq('login')->exec(); + } + + /** + * Test create a action. + * + * @param string $objectType + * @param int $objectID + * @param string $actionType + * @param string $comment + * @param string $extra + * @param string $actor + * @param bool $autoDelete + * @access public + * @return object + */ + public function createTest($objectType, $objectID, $actionType, $comment = '', $extra = '', $actor = '', $autoDelete = true) + { + $_POST['uid'] = ''; + $objectID = $this->objectModel->create($objectType, $objectID, $actionType, $comment, $extra, $actor, $autoDelete); + + unset($_POST); + if(dao::isError()) return dao::getError(); + + return $objectID ? $this->objectModel->getById($objectID) : 0; + } + + /** + * Test update read field of action when view a task/bug. + * + * @param string $objectType + * @param int $objectID + * @access public + * @return array + */ + public function readTest($objectType, $objectID) + { + $this->objectModel->read($objectType, $objectID); + + if(dao::isError()) return dao::getError(); + + global $tester; + $objects = $tester->dao->select('*')->from(TABLE_ACTION)->where('objectID')->eq($objectID)->andWhere('objectType')->eq($objectType)->fetchAll(); + return $objects; + } + + public function getUnreadActionsTest($actionID = 0) + { + $objects = $this->objectModel->getUnreadActions($actionID = 0); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test get product, project, execution of the object. + * + * @param String $objectType + * @param Int $objectID + * @param String $actionType + * @param String $extra + * @access public + * @return array + */ + public function getRelatedFieldsTest($objectType, $objectID, $actionType = '', $extra = '') + { + $objects = $this->objectModel->getRelatedFields($objectType, $objectID, $actionType = '', $extra = ''); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test get actions of an object. + * + * @param string $objectType + * @param int $objectID + * @access public + * @return object + */ + public function getListTest($objectType, $objectID) + { + $objects = $this->objectModel->getList($objectType, $objectID); + + if(dao::isError()) return dao::getError(); + + $objects[$objectID]->extra = trim($objects[$objectID]->extra, "\n"); + return $objects[$objectID]; + } + + /** + * Test process Project Actions change actionStype. + * + * @param array $actions + * @access public + * @return string + */ + public function processProjectActionsTest($actions) + { + global $tester; + $actions = $tester->dao->select('*')->from(TABLE_ACTION)->where('id')->in($actions)->fetchAll('id'); + + $objects = $this->objectModel->processProjectActions($actions); + + if(dao::isError()) return dao::getError(); + + $IDs = array_keys($objects); + return implode(',', $IDs); + } + + /** + * Test get action by id. + * + * @param int $actionID + * @access public + * @return object + */ + public function getByIdTest($actionID) + { + $object = $this->objectModel->getById($actionID); + + if(dao::isError()) return dao::getError(); + + return $object; + } + + /** + * Test get deleted objects. + * + * @param string $type + * @param string $orderBy + * @param object $pager + * @access public + * @return array + */ + public function getTrashesTest($type, $orderBy, $pager) + { + $objects = $this->objectModel->getTrashes($type, $orderBy, $pager); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test get histories of an action. + * + * @param int $actionID + * @access public + * @return array + */ + public function getHistoryTest($actionID) + { + $objects = $this->objectModel->getHistory($actionID); + + if(dao::isError()) return dao::getError(); + + return $objects[$actionID]; + } + + /** + * Test log histories for an action. + * + * @param int $actionID + * @param array $changes + * @access public + * @return array + */ + public function logHistoryTest($actionID, $changes) + { + $this->objectModel->logHistory($actionID, $changes); + + if(dao::isError()) return dao::getError(); + + global $tester; + $objects = $tester->dao->select('*')->from(TABLE_HISTORY)->where('action')->eq($actionID)->fetchAll(); + return $objects; + } + + public function printActionTest($action, $desc = '') + { + $objects = $this->objectModel->printAction($action, $desc = ''); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test get actions as dynamic. + * + * @param string $account + * @param string $period + * @param string $productID + * @param string $projectID + * @param string $executionID + * @param string $date + * @param string $direction + * @access public + * @return int + */ + public function getDynamicTest($account = 'all', $period = 'all', $productID = 'all', $projectID = 'all', $executionID = 'all', $date = '', $direction = 'next') + { + $date = $date == 'today' ? date('Y-m-d', time()) : $date; + $objects = $this->objectModel->getDynamic($account, $period, 'date_desc', null, $productID, $projectID, $executionID, $date, $direction); + + if(dao::isError()) return dao::getError(); + + return count($objects); + } + + public function getActionConditionTest() + { + $objects = $this->objectModel->getActionCondition(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getDynamicBySearchTest($products, $projects, $executions, $queryID, $orderBy = 'date_desc', $pager = null, $date = '', $direction = 'next') + { + $objects = $this->objectModel->getDynamicBySearch($products, $projects, $executions, $queryID, $orderBy = 'date_desc', $pager = null, $date = '', $direction = 'next'); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test get actions by SQL. + * + * @param string $sql + * @param string $orderBy + * @param object $pager + * @access public + * @return int + */ + public function getBySQLTest($sql, $orderBy = 'id_desc', $pager = null) + { + $objects = $this->objectModel->getBySQL($sql, $orderBy, $pager = null); + + if(dao::isError()) return dao::getError(); + + return count($objects); + } + + public function transformActionsTest($actions) + { + $objects = $this->objectModel->transformActions($actions); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test get related data by actions. + * + * @param array $actions + * @param string $field + * @access public + * @return array + */ + public function getRelatedDataByActionsTest($actions, $field) + { + global $tester; + $actions = $tester->dao->select('*')->from(TABLE_ACTION)->where('id')->in($actions)->fetchAll('id'); + + $objects = $this->objectModel->getRelatedDataByActions($actions); + + if(dao::isError()) return dao::getError(); + + return $objects[$field]; + } + + /** + * Test get object label. + * + * @param string $objectType + * @param int $objectID + * @param string $actionType + * @param array $requirements + * @access public + * @return string + */ + public function getObjectLabelTest($objectType, $objectID, $actionType, $requirements) + { + $object = $this->objectModel->getObjectLabel($objectType, $objectID, $actionType, $requirements); + + if(dao::isError()) return dao::getError(); + + return $object; + } + + /** + * Test set objectLink. + * + * @param int $actionID + * @access public + * @return object + */ + public function setObjectLinkTest($actionID) + { + global $tester; + $deptUsers = isset($tester->app->user->dept) ? $tester->loadModel('dept')->getDeptUserPairs($tester->app->user->dept, 'id') : ''; + + $action = $this->objectModel->getByID($actionID); + $action->objectLabel = $this->objectModel->getObjectLabel($action->objectType, $action->objectID, $action->action, array('25' => '25')); + + $object = $this->objectModel->setObjectLink($action, $deptUsers); + + if(dao::isError()) return dao::getError(); + + return $object; + } + + /** + * Test compute the begin date and end date of a period. + * + * @param string $period + * @access public + * @return array + */ + public function computeBeginAndEndTest($period) + { + $date = $this->objectModel->computeBeginAndEnd($period); + + $today = date('Y-m-d'); + $tomorrow = date::tomorrow(); + $yesterday = date::yesterday(); + $twoDaysAgo = date::twoDaysAgo(); + + if($period == 'all') return $date['begin'] == '1970-1-1' and $date['end'] == '2109-1-1'; + if($period == 'today') return $date['begin'] == $today and $date['end'] == $tomorrow; + if($period == 'yesterday') return $date['begin'] == $yesterday and $date['end'] == $today; + if($period == 'twodaysago') return $date['begin'] == $twoDaysAgo and $date['end'] == $yesterday; + if($period == 'latest3days') return $date['begin'] == $twoDaysAgo and $date['end'] == $tomorrow; + if($period == 'thismonth') return $date == date::getThisMonth(); + if($period == 'lastmonth') return $date == date::getLastMonth(); + $func = "get$period"; + extract(date::$func()); + if($period == 'thisweek') return $date['begin'] == $begin and $date['end'] == $end . ' 23:59:59'; + if($period == 'lastweek') return $date['begin'] == $begin and $date['end'] == $end . ' 23:59:59'; + } + + public function printChangesTest($objectType, $histories, $canChangeTag = true) + { + $objects = $this->objectModel->printChanges($objectType, $histories, $canChangeTag = true); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function undeleteTest($actionID) + { + $objects = $this->objectModel->undelete($actionID); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test hide an object. + * + * @param int $actionID + * @access public + * @return object + */ + public function hideOneTest($actionID) + { + $this->objectModel->hideOne($actionID); + + if(dao::isError()) return dao::getError(); + + $object = $this->objectModel->getByID($actionID); + return $object; + } + + /** + * Test hide all deleted objects. + * + * @access public + * @return array + */ + public function hideAllTest() + { + $this->objectModel->hideAll(); + + if(dao::isError()) return dao::getError(); + + global $tester; + $objects = $tester->dao->select('*')->from(TABLE_ACTION)->where('action')->eq('deleted')->fetchAll(); + return $objects; + } + + public function updateCommentTest($actionID) + { + $objects = $this->objectModel->updateComment($actionID); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test build date group by actions. + * + * @param string $direction + * @param string $type + * @param string $orderBy + * @access public + * @return int + */ + public function buildDateGroupTest($direction = 'next', $type = 'today', $orderBy = 'date_desc') + { + $actions = $this->objectModel->getDynamic('all', $type); + $objects = $this->objectModel->buildDateGroup($actions, $direction, $type, $orderBy); + + if(dao::isError()) return dao::getError(); + + $count = 0; + foreach($objects as $object) $count += count($object); + return $count; + } + + public function hasPreOrNextTest($date, $direction = 'next') + { + $objects = $this->objectModel->hasPreOrNext($date, $direction = 'next'); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function saveIndexTest($objectType, $objectID, $actionType) + { + $objects = $this->objectModel->saveIndex($objectType, $objectID, $actionType); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function printActionForGitLabTest($action) + { + $objects = $this->objectModel->printActionForGitLab($action); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function processActionForAPITest($actions, $users = array(), $objectLang = array()) + { + $objects = $this->objectModel->processActionForAPI($actions, $users = array(), $objectLang = array()); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function processDynamicForAPITest($dynamics) + { + $objects = $this->objectModel->processDynamicForAPI($dynamics); + + if(dao::isError()) return dao::getError(); + + return $objects; + } +} diff --git a/test/data/action.yaml b/test/data/action.yaml index 5303274c78..b3c4749d89 100644 --- a/test/data/action.yaml +++ b/test/data/action.yaml @@ -65,7 +65,7 @@ fields: format: "" - field: extra note: "附加参数" - range: 1{4},11,1{22},33,1{22},101,1{22},131,1{22},161,1{3} + range: 1{4},11,1{3}, 2 ,1{18},33,1{22},101,1{22},131,1{22},161,1{3} prefix: "" postfix: "" loop: 0 diff --git a/test/model/action/builddategroup.php b/test/model/action/builddategroup.php new file mode 100755 index 0000000000..e6ddd802f4 --- /dev/null +++ b/test/model/action/builddategroup.php @@ -0,0 +1,32 @@ +#!/usr/bin/env php +buildDateGroup(); +cid=1 +pid=1 + +*/ + +$directionList = array('next', 'pre'); +$typeList = array('today', 'yesterday', 'thisweek', 'lastweek'); +$orderBy = 'date_asc'; + +$action = new actionTest(); + +r($action->buildDateGroupTest($directionList[0], $typeList[0])) && p() && e('3'); // 测试创建下一个动作日期组 今天 +r($action->buildDateGroupTest($directionList[0], $typeList[1])) && p() && e('3'); // 测试创建下一个动作日期组 昨天 +r($action->buildDateGroupTest($directionList[0], $typeList[2])) && p() && e('9'); // 测试创建下一个动作日期组 本周 +r($action->buildDateGroupTest($directionList[0], $typeList[3])) && p() && e('21'); // 测试创建下一个动作日期组 上周 +r($action->buildDateGroupTest($directionList[0], $typeList[0], $orderBy)) && p() && e('3'); // 测试创建下一个动作日期组 今天 +r($action->buildDateGroupTest($directionList[0], $typeList[1], $orderBy)) && p() && e('3'); // 测试创建下一个动作日期组 昨天 +r($action->buildDateGroupTest($directionList[0], $typeList[2], $orderBy)) && p() && e('9'); // 测试创建下一个动作日期组 本周 +r($action->buildDateGroupTest($directionList[0], $typeList[3], $orderBy)) && p() && e('21'); // 测试创建下一个动作日期组 上周 +r($action->buildDateGroupTest($directionList[1], $typeList[0])) && p() && e('3'); // 测试创建下一个动作日期组 今天 +r($action->buildDateGroupTest($directionList[1], $typeList[1])) && p() && e('3'); // 测试创建下一个动作日期组 昨天 +r($action->buildDateGroupTest($directionList[1], $typeList[2])) && p() && e('9'); // 测试创建下一个动作日期组 本周 +r($action->buildDateGroupTest($directionList[1], $typeList[3])) && p() && e('21'); // 测试创建下一个动作日期组 上周 diff --git a/test/model/action/computebeginandend.php b/test/model/action/computebeginandend.php new file mode 100755 index 0000000000..dc2d7221f0 --- /dev/null +++ b/test/model/action/computebeginandend.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +computeBeginAndEnd(); +cid=1 +pid=1 + +*/ + +$typeList = array('all', 'today', 'yesterday', 'twodaysago', 'latest3days', 'thisweek', 'lastweek', 'thismonth', 'lastmonth'); + +$action = new actionTest(); + +r($action->computeBeginAndEndTest($typeList[0])) && p() && e('1'); // 测试计算all的日期 +r($action->computeBeginAndEndTest($typeList[1])) && p() && e('1'); // 测试计算today的日期 +r($action->computeBeginAndEndTest($typeList[2])) && p() && e('1'); // 测试计算yesterday的日期 +r($action->computeBeginAndEndTest($typeList[3])) && p() && e('1'); // 测试计算twodaysago的日期 +r($action->computeBeginAndEndTest($typeList[4])) && p() && e('1'); // 测试计算latest3days的日期 +r($action->computeBeginAndEndTest($typeList[5])) && p() && e('1'); // 测试计算thisweek的日期 +r($action->computeBeginAndEndTest($typeList[6])) && p() && e('1'); // 测试计算lastweek的日期 +r($action->computeBeginAndEndTest($typeList[7])) && p() && e('1'); // 测试计算thismonth的日期 +r($action->computeBeginAndEndTest($typeList[8])) && p() && e('1'); // 测试计算lastmonth的日期 diff --git a/test/model/action/getbyid.php b/test/model/action/getbyid.php new file mode 100755 index 0000000000..8943e9ad2d --- /dev/null +++ b/test/model/action/getbyid.php @@ -0,0 +1,23 @@ +#!/usr/bin/env php +getById(); +cid=1 +pid=1 + +*/ + +$actionIDList = array('1', '2', '3', '4', '5'); + +$action = new actionTest(); + +r($action->getByIdTest($actionIDList[0])) && p('objectType,objectId,action,comment') && e('product,,common,这是一个系统日志测试备注1'); // 测试获取动态1的信息 +r($action->getByIdTest($actionIDList[1])) && p('objectType,objectId,action,comment') && e('story,,extra,这是一个系统日志测试备注2'); // 测试获取动态2的信息 +r($action->getByIdTest($actionIDList[2])) && p('objectType,objectId,action,comment') && e('productplan,,opened,这是一个系统日志测试备注3'); // 测试获取动态3的信息 +r($action->getByIdTest($actionIDList[3])) && p('objectType,objectId,action,comment') && e('release,,created,这是一个系统日志测试备注4'); // 测试获取动态4的信息 +r($action->getByIdTest($actionIDList[4])) && p('objectType,objectId,action,comment') && e('project,,changed,这是一个系统日志测试备注5'); // 测试获取动态5的信息 diff --git a/test/model/action/getbysql.php b/test/model/action/getbysql.php new file mode 100755 index 0000000000..2e186ec2bf --- /dev/null +++ b/test/model/action/getbysql.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +getBySQL(); +cid=1 +pid=1 + +*/ + +$sql1 = "id like '1%'"; +$sql2 = "objectType = 'product'"; +$sql3 = "objectID < 10"; +$sql4 = "action = 'opened'"; +$sql5 = "`read` = '0'"; + +$action = new actionTest(); + +r($action->getBySQLTest($sql1)) && p() && e('12'); // 查询id like %1的动作个数 +r($action->getBySQLTest($sql2)) && p() && e('5'); // 查询objectType = product的动作个数 +r($action->getBySQLTest($sql3)) && p() && e('9'); // 查询objectID < 10的动作个数 +r($action->getBySQLTest($sql4)) && p() && e('3'); // 查询action = opend的动作个数 +r($action->getBySQLTest($sql5)) && p() && e('50'); // 查询read = 0的动作个数 diff --git a/test/model/action/getdynamic.php b/test/model/action/getdynamic.php new file mode 100755 index 0000000000..cab0d92089 --- /dev/null +++ b/test/model/action/getdynamic.php @@ -0,0 +1,42 @@ +#!/usr/bin/env php +getDynamic(); +cid=1 +pid=1 + +*/ + +$accountList = array('all', 'admin', 'dev17', 'test18'); +$typeList = array('all', 'today', 'yesterday', 'thisweek', 'lastweek'); +$productIDList = array('all', 1, 2, 3); +$projectIDList = array('all', 1, 2, 3); +$executionIDList = array('all', 1, 2, 3); +$dateList = array('', 'today'); + + +$action = new actionTest(); + +r($action->getDynamicTest()) && p() && e('100'); // 查找全部动态 +r($action->getDynamicTest($accountList[1])) && p() && e('34'); // 查找用户admin动态 +r($action->getDynamicTest($accountList[2])) && p() && e('33'); // 查找用户dev17动态 +r($action->getDynamicTest($accountList[3])) && p() && e('33'); // 查找用户test18动态 +r($action->getDynamicTest($accountList[0], $typeList[1])) && p() && e('3'); // 查找今天的动态 +r($action->getDynamicTest($accountList[0], $typeList[2])) && p() && e('3'); // 查找昨天的动态 +r($action->getDynamicTest($accountList[0], $typeList[3])) && p() && e('9'); // 查找本周的动态 +r($action->getDynamicTest($accountList[0], $typeList[4])) && p() && e('21'); // 查找上周的动态 +r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[1])) && p() && e('1'); // 查找产品1的动态 +r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[2])) && p() && e('1'); // 查找产品2的动态 +r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[3])) && p() && e('1'); // 查找产品3的动态 +r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[0], $projectIDList[1])) && p() && e('1'); // 查找项目1的动态 +r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[0], $projectIDList[2])) && p() && e('1'); // 查找项目2的动态 +r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[0], $projectIDList[3])) && p() && e('1'); // 查找项目3的动态 +r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[0], $projectIDList[0], $executionIDList[1])) && p() && e('0'); // 查找执行1的动态 +r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[0], $projectIDList[0], $executionIDList[2])) && p() && e('0'); // 查找执行2的动态 +r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[0], $projectIDList[0], $executionIDList[3])) && p() && e('0'); // 查找执行3的动态 +r($action->getDynamicTest($accountList[0], $typeList[0], $productIDList[0], $projectIDList[0], $executionIDList[0], $dateList[1])) && p() && e('97'); // 查找今天的动态 diff --git a/test/model/action/gethistory.php b/test/model/action/gethistory.php new file mode 100755 index 0000000000..4b21386aec --- /dev/null +++ b/test/model/action/gethistory.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +getHistory(); +cid=1 +pid=1 + +*/ +$actionIDList = array('1', '2', '3', '4', '5'); + +$action = new actionTest(); + +r($action->getHistoryTest($actionIDList[0])) && p("0:field,old,new") && e('resolution,1,2'); // 查找actionID为1的历史记录 +r($action->getHistoryTest($actionIDList[1])) && p("0:field,old,new") && e('resolvedBuild,2,3'); // 查找actionID为2的历史记录 +r($action->getHistoryTest($actionIDList[2])) && p("0:field,old,new") && e('resolvedDate,2020-01-01,2020-01-17'); // 查找actionID为3的历史记录 +r($action->getHistoryTest($actionIDList[3])) && p("0:field,old,new") && e('status,doing,done'); // 查找actionID为4的历史记录 +r($action->getHistoryTest($actionIDList[4])) && p("0:field,old,new") && e('resolution,1,2'); // 查找actionID为5的历史记录 diff --git a/test/model/action/getrelateddatabyactions.php b/test/model/action/getrelateddatabyactions.php new file mode 100755 index 0000000000..1918a6e0e9 --- /dev/null +++ b/test/model/action/getrelateddatabyactions.php @@ -0,0 +1,38 @@ +#!/usr/bin/env php +getRelatedDataByActions(); +cid=1 +pid=1 + +*/ + +$actions = array('1,2,3,4,5', '6,7,8,9,10', '11,12,13,14,15', '16,17,18,19,20', '21,22,23,24,25'); + +$action = new actionTest(); + +r($action->getRelatedDataByActionsTest($actions[0], 'objectNames')) && p('project:5') && e('项目集5'); // 获取动态1 2 3 4 5 objectNames的关联信息 +r($action->getRelatedDataByActionsTest($actions[0], 'objectNames')) && p('user:0') && e('guest'); // 获取动态1 2 3 4 5 objectNames的关联信息 +r($action->getRelatedDataByActionsTest($actions[0], 'relatedProjects')) && p('project:5') && e('5'); // 获取动态1 2 3 4 5 relatedProjects的关联信息 +r($action->getRelatedDataByActionsTest($actions[0], 'requirements')) && p() && e('0'); // 获取动态1 2 3 4 5 requirements的关联信息 +r($action->getRelatedDataByActionsTest($actions[1], 'objectNames')) && p('case:10') && e('这个是测试用例10'); // 获取动态6 7 8 9 10 objectNames的关联信息 +r($action->getRelatedDataByActionsTest($actions[1], 'objectNames')) && p('user:0') && e('guest'); // 获取动态6 7 8 9 10 objectNames的关联信息 +r($action->getRelatedDataByActionsTest($actions[1], 'relatedProjects')) && p('case:10') && e('0'); // 获取动态6 7 8 9 10 relatedProjects的关联信息 +r($action->getRelatedDataByActionsTest($actions[1], 'requirements')) && p() && e('0'); // 获取动态6 7 8 9 10 requirements的关联信息 +r($action->getRelatedDataByActionsTest($actions[2], 'objectNames')) && p('todo:15') && e('测试单15的待办'); // 获取动态11 12 13 14 15 objectNames的关联信息 +r($action->getRelatedDataByActionsTest($actions[2], 'objectNames')) && p('user:0') && e('guest'); // 获取动态11 12 13 14 15 objectNames的关联信息 +r($action->getRelatedDataByActionsTest($actions[2], 'relatedProjects')) && p('doc:13') && e('0'); // 获取动态11 12 13 14 15 relatedProjects的关联信息 +r($action->getRelatedDataByActionsTest($actions[2], 'requirements')) && p() && e('0'); // 获取动态11 12 13 14 15 requirements的关联信息 +r($action->getRelatedDataByActionsTest($actions[3], 'objectNames')) && p('caselib:19') && e('这是测试套件名称19'); // 获取动态16 17 18 19 20 objectNames的关联信息 +r($action->getRelatedDataByActionsTest($actions[3], 'objectNames')) && p('user:0') && e('guest'); // 获取动态16 17 18 19 20 objectNames的关联信息 +r($action->getRelatedDataByActionsTest($actions[3], 'relatedProjects')) && p('caselib:19') && e('0'); // 获取动态16 17 18 19 20 relatedProjects的关联信息 +r($action->getRelatedDataByActionsTest($actions[3], 'requirements')) && p() && e('0'); // 获取动态16 17 18 19 20 requirements的关联信息 +r($action->getRelatedDataByActionsTest($actions[4], 'objectNames')) && p('story:25') && e('用户需求25'); // 获取动态21 22 23 24 25 objectNames的关联信息 +r($action->getRelatedDataByActionsTest($actions[4], 'objectNames')) && p('user:0') && e('guest'); // 获取动态21 22 23 24 25 objectNames的关联信息 +r($action->getRelatedDataByActionsTest($actions[4], 'relatedProjects')) && p('story:0') && e(''); // 获取动态21 22 23 24 25 relatedProjects的关联信息 +r($action->getRelatedDataByActionsTest($actions[4], 'requirements')) && p('25') && e('25'); // 获取动态21 22 23 24 25 requirements的关联信息 diff --git a/test/model/action/gettrashes.php b/test/model/action/gettrashes.php new file mode 100755 index 0000000000..0afe21d5a9 --- /dev/null +++ b/test/model/action/gettrashes.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +getTrashes(); +cid=1 +pid=1 + +*/ + +$typeList = array('all', 'hidden'); +$orderBy = array('id_desc', 'id_asc'); +$pager = null; + +$action = new actionTest(); + +r($action->getTrashesTest($typeList[0], $orderBy[0], $pager)) && p('0:objectType,objectId,objectName;1:objectType,objectId,objectName') && e('testsuite,,这是测试套件名称87;story,,软件需求48'); // 查询type all id desc排序的回收站信息 +r($action->getTrashesTest($typeList[0], $orderBy[1], $pager)) && p('0:objectType,objectId,objectName;1:objectType,objectId,objectName') && e('story,,软件需求48;testsuite,,这是测试套件名称87'); // 查询type all id desc排序的回收站信息 +r($action->getTrashesTest($typeList[1], $orderBy[0], $pager)) && p('0:objectType,objectId,objectName') && e('testcase,,这个是测试用例9'); // 查询type hidden id asc排序的回收站信息 +r($action->getTrashesTest($typeList[1], $orderBy[1], $pager)) && p('0:objectType,objectId,objectName') && e('testcase,,这个是测试用例9'); // 查询type hidden id asc排序的回收站信息 diff --git a/test/model/action/hideall.php b/test/model/action/hideall.php new file mode 100755 index 0000000000..0cdccd848f --- /dev/null +++ b/test/model/action/hideall.php @@ -0,0 +1,18 @@ +#!/usr/bin/env php +hideAll(); +cid=1 +pid=1 + +*/ + +$action = new actionTest(); + +r($action->hideAllTest()) && p('0:extra;1:extra;2:extra') && e('2;2;2'); // 隐藏回收站全部信息 +system("./ztest init"); diff --git a/test/model/action/hideone.php b/test/model/action/hideone.php new file mode 100755 index 0000000000..3947173c02 --- /dev/null +++ b/test/model/action/hideone.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +hideOne(); +cid=1 +pid=1 + +*/ +$actionIDList = array('48', '87', '9', '1'); + +$action = new actionTest(); + +r($action->hideOneTest($actionIDList[0])) && p('extra') && e('2'); // 隐藏action 28 +r($action->hideOneTest($actionIDList[1])) && p('extra') && e('2'); // 隐藏action 87 +r($action->hideOneTest($actionIDList[2])) && p('extra') && e('2'); // 隐藏已隐藏action 9 +r($action->hideOneTest($actionIDList[3])) && p('extra') && e('1'); // 隐藏非删除action 1 +system("./ztest init"); diff --git a/test/model/action/processprojectactions.php b/test/model/action/processprojectactions.php new file mode 100755 index 0000000000..0f4e9c94df --- /dev/null +++ b/test/model/action/processprojectactions.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +processProjectActions(); +cid=1 +pid=1 + +*/ + +$actions = array('1,2,3,4,5', '26,27,28,29,30', '51,52,53,54,55', '71,72,73,74,75', '96,97,98,99,100', '5,28,51,74,97'); + +$action = new actionTest(); + +r($action->processProjectActionsTest($actions[0])) && p() && e('5'); // 测试计算action 1 2 3 4 5 的项目动态 +r($action->processProjectActionsTest($actions[1])) && p() && e('28'); // 测试计算action 26 27 28 29 30 的项目动态 +r($action->processProjectActionsTest($actions[2])) && p() && e('51'); // 测试计算action 51 52 53 54 55 的项目动态 +r($action->processProjectActionsTest($actions[3])) && p() && e('74'); // 测试计算action 71 72 73 74 75 的项目动态 +r($action->processProjectActionsTest($actions[4])) && p() && e('97'); // 测试计算action 96 97 98 99 100 的项目动态 +r($action->processProjectActionsTest($actions[5])) && p() && e('5,28,51,74,97'); // 测试计算action 5 28 51 74 97 的项目动态 diff --git a/test/model/action/read.php b/test/model/action/read.php new file mode 100755 index 0000000000..2186ae52a6 --- /dev/null +++ b/test/model/action/read.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +read(); +cid=1 +pid=1 + +*/ + +$objectType = array('product', 'story', 'productplan', 'release', 'project'); +$objectID = array(1,2,3,4,5); + +$action = new actionTest(); + +r($action->readTest($objectType[0], $objectID[0])) && p('0:objectType,objectID,read') && e('product,1,1'); // 测试对action 1 进行阅读操作 +r($action->readTest($objectType[1], $objectID[1])) && p('0:objectType,objectID,read') && e('story,2,1'); // 测试对action 2 进行阅读操作 +r($action->readTest($objectType[2], $objectID[2])) && p('0:objectType,objectID,read') && e('productplan,3,1'); // 测试对action 3 进行阅读操作 +r($action->readTest($objectType[3], $objectID[3])) && p('0:objectType,objectID,read') && e('release,4,1'); // 测试对action 4 进行阅读操作 +r($action->readTest($objectType[4], $objectID[4])) && p('0:objectType,objectID,read') && e('project,5,1'); // 测试对action 5 进行阅读操作 +system("./ztest init"); diff --git a/test/ztest b/test/ztest index 9acae923fd..a0b8b0b451 100755 --- a/test/ztest +++ b/test/ztest @@ -58,6 +58,9 @@ switch($argv[1]) case 'kanban': ztfRun('model/kanban'); break; + case 'action': + ztfRun('model/action'); + break; case 'my': ztfRun('model/my'); break;