diff --git a/test/class/execution.class.php b/test/class/execution.class.php index 8f79831e79..71beb1a838 100644 --- a/test/class/execution.class.php +++ b/test/class/execution.class.php @@ -621,16 +621,16 @@ class executionTest } /** - * Get execution stat data. - * - * @param int $projectID - * @param string $browseType - * @param int $productID - * @param int $branch - * @param bool $withTasks - * @param string $param - * @param string $orderBy - * @param object $pager + * Get execution stat data. + * + * @param int $projectID + * @param string $browseType + * @param int $productID + * @param int $branch + * @param bool $withTasks + * @param string $param + * @param string $orderBy + * @param object $pager * @access public * @return int */ @@ -2287,4 +2287,193 @@ class executionTest return $returns; } } + + /** + * Test Get bugs by search in execution. + * + * @param array $products + * @param int $executionID + * @param string $sql + * @param object $pager + * @param string $orderBy + * @access public + * @return void + */ + public function getSearchBugsTest($products, $executionID, $sql, $pager = null, $orderBy = 'id_desc') + { + $object = $this->objectModel->getSearchBugs($products, $executionID, $sql, $pager, $orderBy); + + if(dao::isError()) + { + $error = dao::getError(); + return $error; + } + else + { + return $object; + } + } + + /** + * Test Get kanban group data. + * + * @param array $stories + * @param array $tasks + * @param array $bugs + * @param string $type + * @access public + * @return void + */ + public function getKanbanGroupDataTest($stories, $tasks, $bugs, $type = 'story') + { + $object = $this->objectModel->getKanbanGroupData($stories, $tasks, $bugs, $type); + + if(dao::isError()) + { + $error = dao::getError(); + return $error; + } + else + { + if(count((array)$object['closed']) == 0 and count((array)$object['nokey']) == 0) return 'empty'; + return $object; + } + } + + /** + * Test Get Prev Kanban. + * + * @param int $executionID + * @access public + * @return void + */ + public function getPrevKanbanTest($executionID) + { + $result = $this->objectModel->getPrevKanban($executionID); + + if(dao::isError()) + { + $error = dao::getError(); + return $error; + } + else + { + return !$result ? 'empty' : $result; + } + } + + /** + * Test save Kanban Data. + * + * @param int $executionID + * @param array $kanbanDatas + * @access public + * @return void + */ + public function saveKanbanDataTest($executionID, $kanbanDatas = '') + { + if($kanbanDatas === '') + { + global $tester; + $contents = array('story', 'wait', 'doing', 'done', 'cancel'); + $stories = $tester->loadModel('story')->getExecutionStories($executionID, 0, 0, 'id_asc'); + $kanbanTasks = $this->objectModel->getKanbanTasks($executionID, "id"); + $kanbanBugs = $tester->loadModel('bug')->getExecutionBugs($executionID); + $users = array(); + $taskAndBugs = array(); + foreach($kanbanTasks as $task) + { + $storyID = $task->storyID; + $status = $task->status; + $users[] = $task->assignedTo; + + $taskAndBugs[$status]["task{$task->id}"] = $task; + } + foreach($kanbanBugs as $bug) + { + $storyID = $bug->story; + $status = $bug->status; + $status = $status == 'active' ? 'wait' : ($status == 'resolved' ? ($bug->resolution == 'postponed' ? 'cancel' : 'done') : $status); + $users[] = $bug->assignedTo; + + $taskAndBugs[$status]["bug{$bug->id}"] = $bug; + } + + $datas = array(); + foreach($contents as $content) + { + if($content != 'story' and !isset($taskAndBugs[$content])) continue; + $datas[$content] = $content == 'story' ? $stories : $taskAndBugs[$content]; + } + $kanbanDatas = $datas; + } + + $object = $this->objectModel->saveKanbanData($executionID, $kanbanDatas); + + if(dao::isError()) + { + $error = dao::getError(); + return $error; + } + else + { + $result = $this->objectModel->getPrevKanban($executionID); + return !$result ? 'empty' : $result; + } + } + + /** + * Test Get lifetime by id list. + * + * @param array $idList + * @access public + * @return void + */ + public function getLifetimeByIdListTest($idList = '') + { + $result = $this->objectModel->getLifetimeByIdList($idList); + + if(dao::isError()) + { + $error = dao::getError(); + return $error; + } + else + { + if(!$result) return 'empty'; + + foreach($result as $id => $lifetime) + { + if(!$lifetime) $result[$id] = 'emptyLifetime'; + } + return $result; + } + } + + /** + * Test Update user view of execution and it's product. + * + * @param int $executionID + * @param string $objectType + * @param array $users + * @access public + * @return void + */ + public function updateUserViewTest($executionID, $objectType = 'sprint', $users = array()) + { + $this->objectModel->updateUserView($executionID, $objectType, $users); + + if(dao::isError()) + { + $error = dao::getError(); + return $error; + } + else + { + if(count($users) > 0) su($users[0]); + + global $tester; + return $tester->app->user->view->sprints; + } + } } diff --git a/test/model/execution/getkanbangroupdata.php b/test/model/execution/getkanbangroupdata.php new file mode 100644 index 0000000000..d2e95793c2 --- /dev/null +++ b/test/model/execution/getkanbangroupdata.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php +getKanbanGroupData(); +cid=1 +pid=1 + +空数据查询 >> empty +查询执行162需求 >> 软件需求246 + +*/ + +$execution = new executionTest(); + +$executionID = 162; +$stories = $tester->loadModel('story')->getExecutionStories($executionID); +$tasks = $execution->getKanbanTasksTest($executionID, false); +$bugs = $tester->loadModel('bug')->getExecutionBugs($executionID); + +r($execution->getKanbanGroupDataTest(array(), array(), array(), 'story')) && p('') && e('empty'); //空数据查询 +r($execution->getKanbanGroupDataTest($stories, $tasks, $bugs, 'story')) && p('246:title') && e('软件需求246'); // 查询执行162需求 diff --git a/test/model/execution/getlifetimebyidlist.php b/test/model/execution/getlifetimebyidlist.php new file mode 100644 index 0000000000..a4ccdbd95b --- /dev/null +++ b/test/model/execution/getlifetimebyidlist.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +getLifetimeByIdList(); +cid=1 +pid=1 + +查询执行103和161 lifetime >> emptyLifetime +查询空执行 lifetime >> empty + +*/ + +$executionIDList = array('103', '161'); + +$execution = new executionTest(); +r($execution->getLifetimeByIdListTest($executionIDList)) && p('103') && e('emptyLifetime'); // 查询执行103和161 lifetime +r($execution->getLifetimeByIdListTest(array('0'))) && p('') && e('empty'); // 查询空执行 lifetime diff --git a/test/model/execution/getprevkanban.php b/test/model/execution/getprevkanban.php new file mode 100644 index 0000000000..a0d65c6793 --- /dev/null +++ b/test/model/execution/getprevkanban.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +getPrevKanban(); +cid=1 +pid=1 + +查询执行162数据 >> empty +保存数据后查询执行162数据 >> 246 + +*/ + +$execution = new executionTest(); + +$emptyExecutionID = 163; +$executionID = 162; + +r($execution->getPrevKanbanTest($emptyExecutionID)) && p('') && e('empty'); //查询执行162数据 +$execution->saveKanbanDataTest($executionID); +r($execution->getPrevKanbanTest($executionID)) && p('story:0') && e('246'); //保存数据后查询执行162数据 diff --git a/test/model/execution/getsearchbugs.php b/test/model/execution/getsearchbugs.php new file mode 100644 index 0000000000..cbc16adcc7 --- /dev/null +++ b/test/model/execution/getsearchbugs.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +getSearchBugs(); +cid=1 +pid=1 + +查询产品1bug >> 测试单转Bug1 +查询项目13bug优先级 >> 3 + +*/ + +$productIDList = array(1 => '正常产品1'); +$executionIDList = array('103'); +$sql = '1=1'; + +$execution = new executionTest(); +r($execution->getSearchBugsTest($productIDList, 0, $sql)) && p('301:title') && e('测试单转Bug1'); // 查询产品1bug +r($execution->getSearchBugsTest(array(), $executionIDList[0], $sql)) && p('303:pri') && e(3); // 查询项目13bug优先级 diff --git a/test/model/execution/savekanbandata.php b/test/model/execution/savekanbandata.php new file mode 100644 index 0000000000..9909bf542b --- /dev/null +++ b/test/model/execution/savekanbandata.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +saveKanbanData(); +cid=1 +pid=1 + +保存执行162看板数据 >> 246 +保存执行162看板空数据 >> empty + +*/ + +$execution = new executionTest(); + +$executionID = 162; +$emptyData = array(); + +r($execution->saveKanbanDataTest($executionID)) && p('story:0') && e('246'); //保存执行162看板数据 +r($execution->saveKanbanDataTest($executionID, $emptyData)) && p('') && e('empty'); //保存执行162看板空数据 diff --git a/test/model/execution/updateuserview.php b/test/model/execution/updateuserview.php new file mode 100644 index 0000000000..a3231232e1 --- /dev/null +++ b/test/model/execution/updateuserview.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +switchDB(); +su('admin'); + +/** + +title=测试executionModel->updateUserView(); +cid=1 +pid=1 + +默认情况下的用户是否有201权限 >> 400 +删除执行201后dev1用户是否有201权限 >> 0 + +*/ + +$executionID = 201; + +$execution = new executionTest(); +r(strpos($execution->updateUserViewTest($executionID), '201,')) && p() && e('400'); // 默认情况下的用户是否有201权限 +$tester->dao->update(TABLE_EXECUTION)->set('deleted')->eq(1)->where('id')->eq($executionID)->exec(); +r(strpos($execution->updateUserViewTest($executionID, 'sprint', array('dev1')), '201,')) && p() && e('0'); // 删除执行201后dev1用户是否有201权限 +$db->restoreDB();