diff --git a/module/story/model.php b/module/story/model.php index 4db7db0cba..9f3e0fbc07 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1374,6 +1374,7 @@ class storyModel extends model $reviewerList = $this->dao->select('story,reviewer,result,version')->from(TABLE_STORYREVIEW)->where('story')->in($storyIdList)->orderBy('version')->fetchGroup('story', 'reviewer'); foreach($storyIdList as $storyID) { + if(!$storyID) continue; $oldStory = $oldStories[$storyID]; $isSuperReviewer = strpos(',' . trim(zget($this->config->story, 'superReviewers', ''), ',') . ',', ',' . $this->app->user->account . ','); @@ -1702,17 +1703,20 @@ class storyModel extends model if($this->session->currentProductType != 'normal' and empty($story->branch) and $planID != 0) $story->plan = $oldStory->plan ? $oldStory->plan . ",$planID" : ",$planID"; /* Change stage. */ - if($planID and $oldStory->stage == 'wait') $story->stage = 'planned'; - if($planID and $this->session->currentProductType != 'normal' and $oldStory->branch == 0) + if($planID) { - if(!isset($oldStoryStages[$storyID][$plan->branch])) + if($oldStory->stage == 'wait') $story->stage = 'planned'; + if($this->session->currentProductType and $this->session->currentProductType != 'normal' and $oldStory->branch == 0) { - $story->stage = 'planned'; - $newStoryStage = new stdclass(); - $newStoryStage->story = $storyID; - $newStoryStage->branch = $plan->branch; - $newStoryStage->stage = $story->stage; - $this->dao->insert(TABLE_STORYSTAGE)->data($newStoryStage)->autoCheck()->exec(); + if(!isset($oldStoryStages[$storyID][$plan->branch])) + { + $story->stage = 'planned'; + $newStoryStage = new stdclass(); + $newStoryStage->story = $storyID; + $newStoryStage->branch = $plan->branch; + $newStoryStage->stage = $story->stage; + $this->dao->insert(TABLE_STORYSTAGE)->data($newStoryStage)->autoCheck()->exec(); + } } } diff --git a/test/class/story.class.php b/test/class/story.class.php index b275ec1197..694ac8bc27 100644 --- a/test/class/story.class.php +++ b/test/class/story.class.php @@ -241,11 +241,11 @@ class storyTest */ public function computeEstimateTest($storyID) { - $objects = $this->objectModel->computeEstimate($storyID); + $this->objectModel->computeEstimate($storyID); if(dao::isError()) return dao::getError(); - return $objects; + return $this->objectModel->getByID($storyID); } /** @@ -266,148 +266,239 @@ class storyTest return $this->objectModel->getByList($storyIdList); } - public function reviewTest($storyID) + /** + * Test review story. + * + * @param int $storyID + * @param array $params + * @access public + * @return void + */ + public function reviewTest($storyID, $params) { - $objects = $this->objectModel->review($storyID); + $_POST = $params; + $changes = $this->objectModel->review($storyID); + unset($_POST); if(dao::isError()) return dao::getError(); - return $objects; + return $this->objectModel->getByID($storyID); } + /** + * Test batch review. + * + * @param int $storyIdList + * @param int $result + * @param int $reason + * @access public + * @return void + */ public function batchReviewTest($storyIdList, $result, $reason) { - $objects = $this->objectModel->batchReview($storyIdList, $result, $reason); + $actions = $this->objectModel->batchReview($storyIdList, $result, $reason); if(dao::isError()) return dao::getError(); - return $objects; + $storyIdList = array_keys($actions); + return $this->objectModel->getByList($storyIdList); } - public function recallTest($storyID) + /** + * Test story subdivide. + * + * @param int $storyID + * @param array $stories + * @access public + * @return void + */ + public function subdivideTest($storyID, $stories, $type) { - $objects = $this->objectModel->recall($storyID); + $this->objectModel->subdivide($storyID, $stories); if(dao::isError()) return dao::getError(); - return $objects; + global $tester; + if($type == 'requirement') + { + return $tester->dao->select('*')->from(TABLE_RELATION)->where('AID')->eq($storyID)->andWhere('AType')->eq($type)->fetchAll(); + } + else + { + return $this->objectModel->getById($storyID); + } } - public function subdivideTest($storyID, $stories) + /** + * Test close a story. + * + * @param int $storyID + * @param array $params + * @access public + * @return void + */ + public function closeTest($storyID, $params) { - $objects = $this->objectModel->subdivide($storyID, $stories); + $_POST = $params; + $changes = $this->objectModel->close($storyID); + unset($_POST); if(dao::isError()) return dao::getError(); - return $objects; + return $changes; } - public function closeTest($storyID) + /** + * Test batch close story. + * + * @param array $params + * @access public + * @return void + */ + public function batchCloseTest($params) { - $objects = $this->objectModel->close($storyID); + $_POST = $params; + $changes = $this->objectModel->batchClose(); + unset($_POST); if(dao::isError()) return dao::getError(); - return $objects; - } - - public function batchCloseTest() - { - $objects = $this->objectModel->batchClose(); - - if(dao::isError()) return dao::getError(); - - return $objects; + $storyIdList = array_keys($changes); + return $this->objectModel->getByList($storyIdList); } + /** + * Test batch change story module. + * + * @param int $storyIdList + * @param int $moduleID + * @access public + * @return void + */ public function batchChangeModuleTest($storyIdList, $moduleID) { - $objects = $this->objectModel->batchChangeModule($storyIdList, $moduleID); + $changes = $this->objectModel->batchChangeModule($storyIdList, $moduleID); if(dao::isError()) return dao::getError(); - return $objects; + $storyIdList = array_keys($changes); + return $this->objectModel->getByList($storyIdList); } + /** + * Test batch change story plan. + * + * @param arary $storyIdList + * @param int $planID + * @param int $oldPlanID + * @access public + * @return void + */ public function batchChangePlanTest($storyIdList, $planID, $oldPlanID = 0) { - $objects = $this->objectModel->batchChangePlan($storyIdList, $planID, $oldPlanID = 0); + $changes = $this->objectModel->batchChangePlan($storyIdList, $planID, $oldPlanID); if(dao::isError()) return dao::getError(); - return $objects; + $storyIdList = array_keys($changes); + return $this->objectModel->getByList($storyIdList); } + /** + * Test batch change story branch. + * + * @param arary $storyIdList + * @param int $branchID + * @param string $confirm + * @param array $plans + * @access public + * @return void + */ public function batchChangeBranchTest($storyIdList, $branchID, $confirm = '', $plans = array()) { - $objects = $this->objectModel->batchChangeBranch($storyIdList, $branchID, $confirm = '', $plans = array()); + $changes = $this->objectModel->batchChangeBranch($storyIdList, $branchID, $confirm, $plans); if(dao::isError()) return dao::getError(); - return $objects; + $storyIdList = array_keys($changes); + return $this->objectModel->getByList($storyIdList); } + /** + * Test batch change stage. + * + * @param arrau $storyIdList + * @param string $stage + * @access public + * @return void + */ public function batchChangeStageTest($storyIdList, $stage) { - $objects = $this->objectModel->batchChangeStage($storyIdList, $stage); + $changes = $this->objectModel->batchChangeStage($storyIdList, $stage); if(dao::isError()) return dao::getError(); - return $objects; + $storyIdList = array_keys($changes); + return $this->objectModel->getByList($storyIdList); } - public function batchToTaskTest($executionID, $projectID = 0) + /** + * Test story batch to task. + * + * @param int $executionID + * @param int $projectID + * @param array $params + * @access public + * @return void + */ + public function batchToTaskTest($executionID, $projectID = 0, $params) { - $objects = $this->objectModel->batchToTask($executionID, $projectID = 0); + $_POST = $params; + $taskIdList = $this->objectModel->batchToTask($executionID, $projectID); + unset($params); if(dao::isError()) return dao::getError(); - return $objects; + global $tester; + return $tester->loadModel('task')->getByList($taskIdList); } - public function assignTest($storyID) + /** + * Test assign a story. + * + * @param int $storyID + * @param string $assignedTo + * @access public + * @return void + */ + public function assignTest($storyID, $assignedTo) { - $objects = $this->objectModel->assign($storyID); + $_POST['assignedTo'] = $assignedTo; + $this->objectModel->assign($storyID); + unset($_POST); if(dao::isError()) return dao::getError(); - return $objects; + return $this->objectModel->getById($storyID); } - public function batchAssignToTest() + /** + * Test batch assign story. + * + * @param array $params + * @access public + * @return void + */ + public function batchAssignToTest($params) { - $objects = $this->objectModel->batchAssignTo(); + $_POST = $params; + $changes = $this->objectModel->batchAssignTo(); + unset($_POST); if(dao::isError()) return dao::getError(); - return $objects; - } - - public function activateTest($storyID) - { - $objects = $this->objectModel->activate($storyID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function setStageTest($storyID) - { - $objects = $this->objectModel->setStage($storyID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getStories2LinkTest($storyID, $type = 'linkStories', $browseType = 'bySearch', $queryID = 0, $storyType = 'story') - { - $objects = $this->objectModel->getStories2Link($storyID, $type = 'linkStories', $browseType = 'bySearch', $queryID = 0, $storyType = 'story'); - - if(dao::isError()) return dao::getError(); - - return $objects; + $storyIdList = array_keys($changes); + return $this->objectModel->getByList($storyIdList); } public function getProductStoriesTest($productID = 0, $branch = 0, $moduleIdList = 0, $status = 'all', $type = 'story', $orderBy = 'id_desc', $hasParent = true, $excludeStories = '', $pager = null) diff --git a/test/model/story/activate.php b/test/model/story/activate.php index 39ef3ec432..c60a1cdd47 100644 --- a/test/model/story/activate.php +++ b/test/model/story/activate.php @@ -1,6 +1,5 @@ loadModel('story'); -r() && p() && e(); \ No newline at end of file +$beforeActivate2 = $tester->story->getById(2); +$beforeActivate63 = $tester->story->getById(63); +$beforeActivate100 = $tester->story->getById(100); +$beforeActivate301 = $tester->story->getById(301); + +$_POST['status'] = 'active'; +$tester->story->activate(2); +$tester->story->activate(63); +$tester->story->activate(100); +$tester->story->activate(301); + +$afterActivate2 = $tester->story->getById(2); +$afterActivate63 = $tester->story->getById(63); +$afterActivate100 = $tester->story->getById(100); +$afterActivate301 = $tester->story->getById(301); + +r($beforeActivate2) && p('status') && e('active'); //查看激活之前的需求状态 +r($beforeActivate63) && p('status') && e('closed'); //查看激活之前的需求状态 +r($beforeActivate100) && p('status') && e('changed'); //查看激活之前的需求状态 +r($beforeActivate301) && p('status') && e('draft'); //查看激活之前的需求状态 +r($afterActivate2) && p('status') && e('active'); //查看激活之后的需求状态 +r($afterActivate63) && p('status') && e('active'); //查看激活之后的需求状态 +r($afterActivate100) && p('status') && e('active'); //查看激活之后的需求状态 +r($afterActivate301) && p('status') && e('active'); //查看激活之后的需求状态 + +system("./ztest init"); diff --git a/test/model/story/assign.php b/test/model/story/assign.php index 5ee0188244..0593a7746e 100644 --- a/test/model/story/assign.php +++ b/test/model/story/assign.php @@ -13,4 +13,11 @@ pid=1 $story = new storyTest(); -r() && p() && e(); \ No newline at end of file +r($story->assignTest(2, 'test2')) && p('id,assignedTo') && e('2,test2'); //指派需求,查看返回的指派人信息 +r($story->assignTest(4, '')) && p('id,assignedTo') && e('4,'); //指派需求,查看返回的指派人信息 +r($story->assignTest(5, 'user10')) && p('id,assignedTo') && e('5,user10'); //指派需求,查看返回的指派人信息 +r($story->assignTest(10, 'admin')) && p('id,assignedTo') && e('10,admin'); //指派需求,查看返回的指派人信息 +r($story->assignTest(100, 'user50')) && p('id,assignedTo') && e('100,user50'); //指派需求,查看返回的指派人信息 +r($story->assignTest(101, 'pm1')) && p('id,assignedTo') && e('101,pm1'); //指派需求,查看返回的指派人信息 + +system("./ztest init"); diff --git a/test/model/story/batchassignto.php b/test/model/story/batchassignto.php index c74594a1cb..3bab2976c7 100644 --- a/test/model/story/batchassignto.php +++ b/test/model/story/batchassignto.php @@ -13,4 +13,17 @@ pid=1 $story = new storyTest(); -r() && p() && e(); \ No newline at end of file +$params['assignedTo'] = 'test20'; +$params['storyIdList'] = array(1, 2, 3, 4, 5, 6); + +$stories = $story->batchAssignToTest($params); + +r(count($stories)) && p() && e('6'); // 批量指派6个需求,查看修改成功的需求数量 +r($stories) && p('1:assignedTo') && e('test20'); // 批量指派6个需求,查看修改成功的需求指派人 +r($stories) && p('2:assignedTo') && e('test20'); // 批量指派6个需求,查看修改成功的需求指派人 +r($stories) && p('3:assignedTo') && e('test20'); // 批量指派6个需求,查看修改成功的需求指派人 +r($stories) && p('4:assignedTo') && e('test20'); // 批量指派6个需求,查看修改成功的需求指派人 +r($stories) && p('5:assignedTo') && e('test20'); // 批量指派6个需求,查看修改成功的需求指派人 +r($stories) && p('6:assignedTo') && e('test20'); // 批量指派6个需求,查看修改成功的需求指派人 + +system("./ztest init"); diff --git a/test/model/story/batchchangebranch.php b/test/model/story/batchchangebranch.php index 0cbc7d8d94..4e3649eb12 100644 --- a/test/model/story/batchchangebranch.php +++ b/test/model/story/batchchangebranch.php @@ -12,5 +12,12 @@ pid=1 */ $story = new storyTest(); +$storyIdList = array(2, 4, 6); -r() && p() && e(); \ No newline at end of file +$stories = $story->batchChangeBranchTest($storyIdList, 2); + +r(count($stories)) && p() && e('3'); // 批量修改需求的所属分支,判断被修改分支需求的数量 +r($stories) && p('2:branch') && e('2'); // 批量修改需求的所属分支,判断需求2修改后的分支ID +r($stories) && p('4:branch') && e('2'); // 批量修改需求的所属分支,判断需求4修改后的分支ID +r($stories) && p('6:branch') && e('2'); // 批量修改需求的所属分支,判断需求6修改后的分支ID +system("./ztest init"); diff --git a/test/model/story/batchchangemodule.php b/test/model/story/batchchangemodule.php index 407b110b83..fa9b72b7b6 100644 --- a/test/model/story/batchchangemodule.php +++ b/test/model/story/batchchangemodule.php @@ -11,6 +11,15 @@ pid=1 */ -$story = new storyTest(); +$story = new storyTest(); +$storyIdList = array(1, 2, 3, 4, 5, 6); +$stories = $story->batchChangeModuleTest($storyIdList, 1366); -r() && p() && e(); \ No newline at end of file +r(count($stories)) && p() && e('6'); // 批量修改6个需求的模块,查看被修改模块的需求数量 +r($stories) && p('1:module') && e('1366'); // 批量修改6个需求的模块,查看需求1修改后的模块ID +r($stories) && p('2:module') && e('1366'); // 批量修改6个需求的模块,查看需求2修改后的模块ID +r($stories) && p('3:module') && e('1366'); // 批量修改6个需求的模块,查看需求3修改后的模块ID +r($stories) && p('4:module') && e('1366'); // 批量修改6个需求的模块,查看需求4修改后的模块ID +r($stories) && p('5:module') && e('1366'); // 批量修改6个需求的模块,查看需求5修改后的模块ID +r($stories) && p('6:module') && e('1366'); // 批量修改6个需求的模块,查看需求6修改后的模块ID +system("./ztest init"); diff --git a/test/model/story/batchchangeplan.php b/test/model/story/batchchangeplan.php index f6fad944df..895ebacd51 100644 --- a/test/model/story/batchchangeplan.php +++ b/test/model/story/batchchangeplan.php @@ -11,6 +11,23 @@ pid=1 */ -$story = new storyTest(); +$story = new storyTest(); +$storyIdList = array(1, 2, 3, 4, 5, 6); +$stories1 = $story->batchChangePlanTest($storyIdList, 1366); +$stories2 = $story->batchChangePlanTest($storyIdList, 1400, 1366); -r() && p() && e(); \ No newline at end of file +r(count($stories1)) && p() && e('6'); // 批量修改6个需求的计划,查看被修改计划的需求数量 +r(count($stories2)) && p() && e('6'); // 批量修改6个需求的计划,查看被修改计划的需求数量 +r($stories1) && p('1:plan') && e(',1366'); // 批量修改6个需求的计划,查看需求1修改后的计划ID +r($stories1) && p('2:plan') && e(',1366'); // 批量修改6个需求的计划,查看需求2修改后的计划ID +r($stories1) && p('3:plan') && e(',1366'); // 批量修改6个需求的计划,查看需求3修改后的计划ID +r($stories1) && p('4:plan') && e(',1366'); // 批量修改6个需求的计划,查看需求4修改后的计划ID +r($stories1) && p('5:plan') && e(',1366'); // 批量修改6个需求的计划,查看需求5修改后的计划ID +r($stories1) && p('6:plan') && e(',1366'); // 批量修改6个需求的计划,查看需求6修改后的计划ID +r($stories2) && p('1:plan') && e(',1366,1400'); // 批量修改6个需求的计划,查看需求1修改后的计划ID +r($stories2) && p('2:plan') && e(',1366,1400'); // 批量修改6个需求的计划,查看需求2修改后的计划ID +r($stories2) && p('3:plan') && e(',1366,1400'); // 批量修改6个需求的计划,查看需求3修改后的计划ID +r($stories2) && p('4:plan') && e(',1366,1400'); // 批量修改6个需求的计划,查看需求4修改后的计划ID +r($stories2) && p('5:plan') && e(',1366,1400'); // 批量修改6个需求的计划,查看需求5修改后的计划ID +r($stories2) && p('6:plan') && e(',1366,1400'); // 批量修改6个需求的计划,查看需求6修改后的计划ID +system("../../ztest init"); diff --git a/test/model/story/batchchangestage.php b/test/model/story/batchchangestage.php index 76f971ccb0..00513a499a 100644 --- a/test/model/story/batchchangestage.php +++ b/test/model/story/batchchangestage.php @@ -11,6 +11,14 @@ pid=1 */ -$story = new storyTest(); +$story = new storyTest(); +$storyIdList = array(100, 101, 102, 106, 110, 114); +$result = $story->batchChangeStageTest($storyIdList, 'developing'); -r() && p() && e(); \ No newline at end of file +r(count($result)) && p() && e('5'); // 批量修改6个需求的阶段,查看被修改阶段的需求数量 +r($result) && p('101:stage') && e('developing'); // 批量修改6个需求的阶段,查看需求101修改后的阶段 +r($result) && p('102:stage') && e('developing'); // 批量修改6个需求的阶段,查看需求102修改后的阶段 +r($result) && p('106:stage') && e('developing'); // 批量修改6个需求的阶段,查看需求104修改后的阶段 +r($result) && p('110:stage') && e('developing'); // 批量修改6个需求的阶段,查看需求110修改后的阶段 +r($result) && p('114:stage') && e('developing'); // 批量修改6个需求的阶段,查看需求114修改后的阶段 +system("./ztest init"); diff --git a/test/model/story/batchclose.php b/test/model/story/batchclose.php index 592d27b676..60d9b06107 100644 --- a/test/model/story/batchclose.php +++ b/test/model/story/batchclose.php @@ -12,5 +12,22 @@ pid=1 */ $story = new storyTest(); +$storyIdList = array(1, 2, 3, 4, 5, 6); +$closedReasons = array(1 => 'done', 2 => 'willnotdo', 3 => 'putoff', 4 => 'duplicate', 5 => 'cancel', 6 => 'bydesign'); +$duplicateList = array(1 => '', 2 => '', 3 => '', 4 => 8, 5 => '', 6 => ''); +$childStoriesIDList = array(1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => ''); -r() && p() && e(); \ No newline at end of file +$params['storyIdList'] = $storyIdList; +$params['closedReasons'] = $closedReasons; +$params['duplicateStoryIDList'] = $duplicateList; +$params['childStoriesIDList'] = $childStoriesIDList; +$stories = $story->batchCloseTest($params); + +r(count($stories)) && p() && e('6'); // 批量关闭6个需求,查看被关闭的需求数量 +r($stories) && p('1:status,stage,closedReason,duplicateStory') && e('closed,closed,done,0'); // 批量关闭需求,查看需求1被关闭后的字段 +r($stories) && p('2:status,stage,closedReason,duplicateStory') && e('closed,closed,willnotdo,0'); // 批量关闭需求,查看需求2被关闭后的字段 +r($stories) && p('3:status,stage,closedReason,duplicateStory') && e('closed,closed,putoff,0'); // 批量关闭需求,查看需求3被关闭后的字段 +r($stories) && p('4:status,stage,closedReason,duplicateStory') && e('closed,closed,duplicate,8'); // 批量关闭需求,查看需求4被关闭后的字段 +r($stories) && p('5:status,stage,closedReason,duplicateStory') && e('closed,closed,cancel,0'); // 批量关闭需求,查看需求5被关闭后的字段 +r($stories) && p('6:status,stage,closedReason,duplicateStory') && e('closed,closed,bydesign,0'); // 批量关闭需求,查看需求6被关闭后的字段 +system("./ztest init"); diff --git a/test/model/story/batchreview.php b/test/model/story/batchreview.php index 12ca9bc1ae..00bf0d52cb 100644 --- a/test/model/story/batchreview.php +++ b/test/model/story/batchreview.php @@ -13,4 +13,18 @@ pid=1 $story = new storyTest(); -r() && p() && e(); \ No newline at end of file +$storyIdList1 = array(302, 304, ''); +$storyIdList2 = array(308, 310, 0); +$storyIdList3 = array(314, 316, 2); + +$review1 = $story->batchReviewTest($storyIdList1, 'pass', ''); +$review2 = $story->batchReviewTest($storyIdList2, 'reject', 'done'); +$review3 = $story->batchReviewTest($storyIdList3, 'pass', ''); + +r(count($review1)) && p() && e('2'); // 批量评审传入三个ID,查看被评审的需求数量 +r($review1) && p('302:status,stage,closedReason') && e('active,projected,done'); // 批量评审需求,查看被评审后的需求状态、阶段等信息 +r(count($review2)) && p() && e('2'); // 批量评审传入三个ID,查看被评审的需求数量 +r($review2) && p('308:status,stage,closedReason') && e('closed,closed,bydesign'); // 批量评审需求,查看被评审后的需求状态、阶段等信息 +r(count($review3)) && p() && e('2'); // 批量评审传入三个ID,查看被评审的需求数量 +r($review3) && p('314:status,stage,closedReason') && e('active,projected,cancel'); // 批量评审需求,查看被评审后的需求状态、阶段等信息 +system("./ztest init"); diff --git a/test/model/story/batchtotask.php b/test/model/story/batchtotask.php index e9b205347d..0750f21da0 100644 --- a/test/model/story/batchtotask.php +++ b/test/model/story/batchtotask.php @@ -13,4 +13,16 @@ pid=1 $story = new storyTest(); -r() && p() && e(); \ No newline at end of file +$params['storyIdList'] = array(66, 68, 70, 102, 220, 320); +$params['type'] = 'test'; +$params['fields'] = array('assignedTo'); + +$tasks = $story->batchToTaskTest(101, 11, $params); + +r(count($tasks)) && p() && e('5'); //6个需求批量转任务,查看转化后的数量 +r($tasks) && p('911:project,execution,name,status,pri,type,assignedTo') && e('11,101,软件需求66,wait,0,test,'); //查看从需求转化过来的任务的名称、状态、优先级等字段 +r($tasks) && p('912:project,execution,name,status,pri,type,assignedTo') && e('11,101,软件需求68,wait,0,test,'); //查看从需求转化过来的任务的名称、状态、优先级等字段 +r($tasks) && p('913:project,execution,name,status,pri,type,assignedTo') && e('11,101,软件需求70,wait,0,test,'); //查看从需求转化过来的任务的名称、状态、优先级等字段 +r($tasks) && p('914:project,execution,name,status,pri,type,assignedTo') && e('11,101,软件需求102,wait,0,test,'); //查看从需求转化过来的任务的名称、状态、优先级等字段 +r($tasks) && p('915:project,execution,name,status,pri,type,assignedTo') && e('11,101,软件需求220,wait,0,test,'); //查看从需求转化过来的任务的名称、状态、优先级等字段 +system("./ztest init"); diff --git a/test/model/story/batchupdate.php b/test/model/story/batchupdate.php index 6b953a38b6..682280afcc 100644 --- a/test/model/story/batchupdate.php +++ b/test/model/story/batchupdate.php @@ -12,5 +12,38 @@ pid=1 */ $story = new storyTest(); +$stories = array(); +$stories['titles'] = array(12 => '测试软件需求1', 14 => '测试软件需求2'); +$stories['colors'] = array(12 => '', 14 => ''); +$stories['pris'] = array(12 => 1, 14 => 3); +$stories['estimates'] = array(12 => 1, 14 => 3); +$stories['modules'] = array(12 => 2221, 14 => 2223); +$stories['plans'] = array(12 => 1, 14 => 3); +$stories['assignedTo'] = array(12 => 'admin', 14 => 'test10'); +$stories['sources'] = array(12 => 'customer', 14 => 'po'); +$stories['sourceNote'] = array(12 => '测试软件需求来源备注1', 14 => '测试软件需求来源备注2'); +$stories['category'] = array(12 => 'feature', 14 => 'improve'); +$stories['keywords'] = array(12 => '关键词111', 14 => '关键词333'); +$stories['storyIdList'] = array(12, 14); -r() && p() && e(); \ No newline at end of file +$requirements['titles'] = array(13 => '测试用户需求1', 15 => '测试用户需求2'); +$requirements['colors'] = array(13 => '', 15 => ''); +$requirements['pris'] = array(13 => 1, 15 => 3); +$requirements['estimates'] = array(13 => 1, 15 => 3); +$requirements['modules'] = array(13 => 2221, 15 => 2223); +$requirements['plans'] = array(13 => 1, 15 => 3); +$requirements['assignedTo'] = array(13 => 'admin', 15 => 'test10'); +$requirements['sources'] = array(13 => 'customer', 15 => 'po'); +$requirements['sourceNote'] = array(13 => '测试用户需求来源备注1', 15 => '测试用户需求来源备注2'); +$requirements['category'] = array(13 => 'feature', 15 => 'improve'); +$requirements['keywords'] = array(13 => '关键词111', 15 => '关键词333'); +$requirements['storyIdList'] = array(13, 15); + +$result1 = $story->batchUpdateTest($stories); +$result2 = $story->batchUpdateTest($requirements); + +r(count($result1)) && p() && e('2'); // 更新两条软件需求,判断返回的需求总量 +r(count($result2)) && p() && e('2'); // 更新两条用户需求,判断返回的需求总量 +r($result1) && p('14:title,type,pri,sourceNote,estimate,module') && e('测试软件需求2,story,3,测试来源备注2,3,2223'); // 更新两条软件需求,判断返回的title、type等信息 +r($result2) && p('15:title,type,pri,sourceNote,estimate,module') && e('测试用户需求2,requirement,3,测试来源备注2,3,2221'); // 更新两条用户需求,判断返回的title、type等信息 +system("./ztest init"); diff --git a/test/model/story/close.php b/test/model/story/close.php index c120b94f0a..70b83d73a0 100644 --- a/test/model/story/close.php +++ b/test/model/story/close.php @@ -12,5 +12,13 @@ pid=1 */ $story = new storyTest(); +$changes1 = $story->closeTest(1, array('closedReason' => 'done')); +$changes2 = $story->closeTest(2, array('closedReason' => 'willnotdo')); -r() && p() && e(); \ No newline at end of file +r($changes1) && p('0:field,old,new') && e('assigedTo,,closed'); // 关闭一个用户需求,查看变更的字段1 +r($changes1) && p('1:field,old,new') && e('status,active,closed'); // 关闭一个用户需求,查看变更的字段2 +r($changes1) && p('2:field,old,new') && e('stage,wait,closed'); // 关闭一个用户需求,查看变更的字段3 +r($changes2) && p('0:field,old,new') && e('closedReason,subdivided,willnotdo'); // 关闭一个软件需求,查看变更的字段1 +r($changes2) && p('1:field,old,new') && e('assignedTo,,closed'); // 关闭一个软件需求,查看变更的字段2 +r($changes2) && p('2:field,old,new') && e('status,active,closed'); // 关闭一个软件需求,查看变更的字段3 +system("./ztest init"); diff --git a/test/model/story/getproductstories.php b/test/model/story/getproductstories.php index 86e125f506..e67ed97148 100644 --- a/test/model/story/getproductstories.php +++ b/test/model/story/getproductstories.php @@ -11,6 +11,11 @@ pid=1 */ -$story = new storyTest(); +global $tester; +$stories1 = $tester->loadModel('story')->getProductStories(1); -r() && p() && e(); \ No newline at end of file +r(count($stories1)) && p() && e('2'); // 获取需求1可关联的需求数量 +r(count($stories2)) && p() && e('2'); // 获取需求2可关联的需求数量 +r($stories1) && p('2:type,product') && e('story,1'); // 获取需求1可关联的需求id、product + +r() && p() && e(); diff --git a/test/model/story/getstories2link.php b/test/model/story/getstories2link.php index 6466e531f9..782e76833b 100644 --- a/test/model/story/getstories2link.php +++ b/test/model/story/getstories2link.php @@ -1,6 +1,5 @@ loadModel('story')->getStories2Link(1, 'linkStories', 'bySearch', 0, 'requirement'); +$stories2 = $tester->loadModel('story')->getStories2Link(2); -r() && p() && e(); \ No newline at end of file +r(count($stories1)) && p() && e('2'); // 获取需求1可关联的需求数量 +r(count($stories2)) && p() && e('2'); // 获取需求2可关联的需求数量 +r($stories1) && p('2:type,product') && e('story,1'); // 获取需求1可关联的需求id、product +r($stories2) && p('1:type,product') && e('requirement,1'); // 获取需求2可关联的需求id、product diff --git a/test/model/story/recall.php b/test/model/story/recall.php index fa13839236..53901f440c 100644 --- a/test/model/story/recall.php +++ b/test/model/story/recall.php @@ -1,6 +1,5 @@ loadModel('story')->getByID(2); +$tester->loadModel('story')->recall(2); +$afterRecall = $tester->story->getByID(2); + +r($beforeRecall) && p('id,title,status') && e('2,用户需求版本一62,active'); // 撤回评审之前的状态信息 +r($afterRecall) && p('id,title,status') && e('2,用户需求版本一62,draft'); // 撤回评审之后的状态信息 +system("./ztest init"); diff --git a/test/model/story/review.php b/test/model/story/review.php index d9e5c6b30a..05be4f4c90 100644 --- a/test/model/story/review.php +++ b/test/model/story/review.php @@ -12,5 +12,14 @@ pid=1 */ $story = new storyTest(); +$pass['result'] = 'pass'; +$reject['result'] = 'reject'; -r() && p() && e(); \ No newline at end of file +$review1 = $story->reviewTest(2, array()); +$review2 = $story->reviewTest(302, $pass); +$review3 = $story->reviewTest(304, $reject); + +r($review1[0]) && p() && e('必须选择评审意见'); // 评审ID为2的需求,不传入评审意见,给出没有选择评审意见的提示 +r($review2) && p('status') && e('active'); // 评审一个草稿的需求,传入评审意见为通过,状态变为激活 +r($review3) && p('status') && e('closed'); // 评审一个草稿的需求,传入评审意见为拒绝,状态变为关闭 +system("./ztest init"); diff --git a/test/model/story/setstage.php b/test/model/story/setstage.php index e124060330..2517cabda7 100644 --- a/test/model/story/setstage.php +++ b/test/model/story/setstage.php @@ -13,4 +13,21 @@ pid=1 $story = new storyTest(); -r() && p() && e(); \ No newline at end of file +$before = $tester->story->getById(2); + +/* 为需求2拆分几个任务. */ +$tester->dao->update(TABLE_TASK)->set('story')->eq(2)->where('execution')->eq(101)->exec(); +$tester->story->setStage(2); + +$after1 = $tester->story->getById(2); + +/* 把需求2下面的任务都完成. */ +$tester->dao->update(TABLE_TASK)->set('status')->eq('done')->where('story')->eq(2)->exec(); +$tester->story->setStage(2); + +$after2 = $tester->story->getById(2); + +r($before) && p('stage') && e('projected'); //查看设置之后的需求状态 +r($after1) && p('stage') && e('testing'); //查看设置之后的需求状态 +r($after2) && p('stage') && e('tested'); //查看设置之后的需求状态 +system("./ztest init"); diff --git a/test/model/story/subdivide.php b/test/model/story/subdivide.php index db6333ac88..d6864e04f4 100644 --- a/test/model/story/subdivide.php +++ b/test/model/story/subdivide.php @@ -12,5 +12,16 @@ pid=1 */ $story = new storyTest(); +$storyIdList1 = array(2, 4, 6); +$storyIdList2 = array(8, 10, 12); -r() && p() && e(); \ No newline at end of file +$result1 = $story->subdivideTest(1, $storyIdList1, 'requirement'); +$result2 = $story->subdivideTest(2, $storyIdList2, 'story'); + +r(count($result1)) && p() && e('3'); // 将用户需求1拆分三个软件需求,查看relation表记录的数量 +r($result1) && p('0:AID,BID,relation') && e('1,2,subdivideinto'); // 将用户需求1拆分三个软件需求,查看relation表记录的关系 +r($result1) && p('2:AID,BID,relation') && e('1,6,subdivideinto'); // 将用户需求1拆分三个软件需求,查看relation表记录的关系 +r(count($result2->children)) && p() && e('3'); // 将软件需求2拆分三个子需求,查看子需求的数量 +r($result2->children) && p('8:parent,title,id') && e('2,这里是需求来源备注8,8'); // 将软件需求2拆分三个子需求,查看子需求8的parent、title等字段 +r($result2->children) && p('12:parent,title,id') && e('2,这里是需求来源备注12,12'); // 将软件需求2拆分三个子需求,查看子需求12的parent、title等字段 +system("./ztest init");