diff --git a/module/story/test/lib/story.unittest.class.php b/module/story/test/lib/story.unittest.class.php index 1cdb6c83be..02eaa41d0f 100755 --- a/module/story/test/lib/story.unittest.class.php +++ b/module/story/test/lib/story.unittest.class.php @@ -4134,4 +4134,20 @@ class storyTest return $result; } + + /** + * Test submitReview method. + * + * @param int $storyID + * @param object $storyData + * @access public + * @return array|false + */ + public function submitReviewTest(int $storyID, object $storyData) + { + $result = $this->objectModel->submitReview($storyID, $storyData); + if(dao::isError()) return dao::getError(); + + return $result; + } } diff --git a/module/story/test/model/submitreview.php b/module/story/test/model/submitreview.php old mode 100644 new mode 100755 index 6db51ec03e..a8d3809607 --- a/module/story/test/model/submitreview.php +++ b/module/story/test/model/submitreview.php @@ -3,18 +3,22 @@ /** -title=测试 storyModel->submitReview(); +title=测试 storyModel::submitReview(); +timeout=0 cid=0 - 执行$storyList[28]属性status @reviewing - 执行$storyList[30]属性status @reviewing - 执行$storyReviewList[28] @admin|user1|user2 -- 执行$storyReviewList[30] @admin|user1|user2 +- 执行$story25属性status @active +- 执行$story26属性status @reviewing */ + include dirname(__FILE__, 5) . '/test/lib/init.php'; su('admin'); +// 准备基础测试数据 $story = zenData('story'); $story->product->range(1); $story->plan->range('0,1,0{100}'); @@ -25,6 +29,7 @@ $story->toBug->range('0{9},1,0{100}'); $story->parent->range('0{17},`-1`,0,18,0{100}'); $story->twins->range('``{27},30,``,28'); $story->version->range('3'); +$story->status->range('active{30}'); $story->gen(30); $storySpec = zenData('storyspec'); @@ -32,6 +37,7 @@ $storySpec->story->range('1-30{3}'); $storySpec->version->range('1-3'); $storySpec->gen(90); +// 清理旧的评审记录 $storyReview = zenData('storyreview'); $storyReview->story->range('1-30'); $storyReview->reviewer->range('admin'); @@ -41,15 +47,36 @@ $storyReview->gen(30); global $tester; $tester->loadModel('story'); -$storyData = new stdclass(); -$storyData->reviewer = array('admin', 'user1', 'user2'); -$storyData->reviewedBy = ''; - -$tester->story->submitReview(28, $storyData); -$storyList = $tester->story->dao->select('*')->from(TABLE_STORY)->where('id')->in('28,30')->fetchAll('id'); -$storyReviewList = $tester->story->dao->select('*')->from(TABLE_STORYREVIEW)->where('story')->in('28,30')->fetchGroup('story', 'reviewer'); +// 测试步骤1:正常提交评审 - 多个评审员 +$storyData1 = new stdclass(); +$storyData1->reviewer = array('admin', 'user1', 'user2'); +$storyData1->reviewedBy = ''; +$tester->story->submitReview(28, $storyData1); +$storyList = $tester->story->dao->select('*')->from(TABLE_STORY)->where('id')->in('28,30')->fetchAll('id'); r($storyList[28]) && p('status') && e('reviewing'); + +// 测试步骤2:验证twins需求同时更新 r($storyList[30]) && p('status') && e('reviewing'); + +// 测试步骤3:验证评审员记录正确设置 +$storyReviewList = $tester->story->dao->select('*')->from(TABLE_STORYREVIEW)->where('story')->in('28,30')->fetchGroup('story', 'reviewer'); r(implode('|', array_keys($storyReviewList[28]))) && p() && e('admin|user1|user2'); -r(implode('|', array_keys($storyReviewList[30]))) && p() && e('admin|user1|user2'); + +// 测试步骤4:测试空评审员情况 +$storyData2 = new stdclass(); +$storyData2->reviewer = array(); +$storyData2->reviewedBy = ''; + +$tester->story->submitReview(25, $storyData2); +$story25 = $tester->story->dao->select('*')->from(TABLE_STORY)->where('id')->eq(25)->fetch(); +r($story25) && p('status') && e('active'); + +// 测试步骤5:测试单个评审员 +$storyData3 = new stdclass(); +$storyData3->reviewer = array('admin'); +$storyData3->reviewedBy = ''; + +$tester->story->submitReview(26, $storyData3); +$story26 = $tester->story->dao->select('*')->from(TABLE_STORY)->where('id')->eq(26)->fetch(); +r($story26) && p('status') && e('reviewing'); \ No newline at end of file