From fce0afb0b21ddcc6c9947c5488c0f7c489fa753c Mon Sep 17 00:00:00 2001 From: sunguangming Date: Mon, 3 Jun 2024 17:01:44 +0800 Subject: [PATCH] * Compatible unit test, remove unused code. --- module/story/model.php | 30 ++----------------- .../story/test/lib/story.unittest.class.php | 3 ++ module/story/test/model/close.php | 11 +++---- 3 files changed, 11 insertions(+), 33 deletions(-) diff --git a/module/story/model.php b/module/story/model.php index 536f3515b8..12ed3ad2e3 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1430,13 +1430,12 @@ class storyModel extends model return false; } - if(strpos($this->config->story->close->requiredFields, 'comment') !== false and !$this->post->comment) dao::$errors['comment'][] = sprintf($this->lang->error->notempty, $this->lang->comment); + if(strpos($this->config->{$oldStory->type}->close->requiredFields, 'comment') !== false and !$this->post->comment) dao::$errors['comment'][] = sprintf($this->lang->error->notempty, $this->lang->comment); $this->lang->story->comment = $this->lang->comment; - $moduleName = $this->app->rawModule; $this->dao->update(TABLE_STORY)->data($story, 'comment,closeSync') ->autoCheck() - ->batchCheck($this->config->{$moduleName}->close->requiredFields, 'notempty') + ->batchCheck($this->config->{$oldStory->type}->close->requiredFields, 'notempty') ->checkIF($story->closedReason == 'duplicate', 'duplicateStory', 'notempty') ->checkFlow() ->where('id')->eq($storyID) @@ -1445,7 +1444,6 @@ class storyModel extends model /* Update parent story status and stage. */ if($oldStory->parent > 0) $this->updateParentStatus($storyID, $oldStory->parent); - //if($oldStory->isParent == '1') $this->closeAllChildren($storyID, $story->closedReason); if(!dao::isError()) { $this->setStage($storyID); @@ -1502,7 +1500,6 @@ class storyModel extends model /* Update parent story status. */ if($oldStory->parent > 0) $this->updateParentStatus($storyID, $oldStory->parent); - //if($oldStory->isParent == '1') $this->closeAllChildren($storyID, $story->closedReason); $this->setStage($storyID); $changes = common::createChanges($oldStory, $story); @@ -2279,29 +2276,6 @@ class storyModel extends model return $this->formatStories($stories, $type, $limit); } - /** - * 关闭父需求的所有子需求。 - * Close all children of a story. - * - * @param int $storyID - * @param string closedReason - * @access public - * @return void - */ - public function closeAllChildren(int $storyID, string $closedReason) - { - $childIdList = $this->getAllChildId($storyID, false, true); - $this->dao->update(TABLE_STORY) - ->set('status')->eq('closed') - ->set('stage')->eq('closed') - ->set('closedReason')->eq($closedReason) - ->where('id')->in($childIdList) - ->exec(); - - $this->loadModel('action'); - foreach($childIdList as $childID) $this->action->create('story', $childID, 'closedbyparent'); - } - /** * 获取需求的所有子需求ID。 * Get all child stories of a story. diff --git a/module/story/test/lib/story.unittest.class.php b/module/story/test/lib/story.unittest.class.php index edbb50db8f..96d73c3f5b 100644 --- a/module/story/test/lib/story.unittest.class.php +++ b/module/story/test/lib/story.unittest.class.php @@ -411,6 +411,9 @@ class storyTest */ public function closeTest(int $storyID, object $postData) { + global $tester; + $tester->loadModel('requirement'); + $tester->loadModel('epic'); $this->objectModel->close($storyID, $postData); if(dao::isError()) return dao::getError(); diff --git a/module/story/test/model/close.php b/module/story/test/model/close.php index 51fba3f995..7ea70c804f 100755 --- a/module/story/test/model/close.php +++ b/module/story/test/model/close.php @@ -4,6 +4,7 @@ /** title=测试 storyModel->close(); +timeout=0 cid=0 - 关闭一个用户需求,查看状态 @@ -19,7 +20,7 @@ cid=0 - 关闭一个重复了的需求,但缺少重复的需求的ID,查看状态 - 属性status @~~ - 属性closedReason @~~ - - 属性duplicateStory @『重复研发需求』不能为空。 + - 属性duplicateStory @『重复需求』不能为空。 */ include dirname(__FILE__, 5) . '/test/lib/init.php'; @@ -58,7 +59,7 @@ $story2 = $story->closeTest(2, $postData2); $story3 = $story->closeTest(3, $postData3); $story4 = $story->closeTest(4, $postData4); -r($story1) && p('status,closedReason') && e('closed,done'); // 关闭一个用户需求,查看状态 -r($story2) && p('status,closedReason') && e('closed,willnotdo'); // 关闭一个软件需求,查看状态 -r($story3) && p('status,closedReason,duplicateStory') && e('closed,duplicate,5'); // 关闭一个重复了的需求,查看状态 -r($story4) && p('status,closedReason,duplicateStory') && e('~~,~~,『重复研发需求』不能为空。'); // 关闭一个重复了的需求,但缺少重复的需求的ID,查看状态 +r($story1) && p('status,closedReason') && e('closed,done'); // 关闭一个用户需求,查看状态 +r($story2) && p('status,closedReason') && e('closed,willnotdo'); // 关闭一个软件需求,查看状态 +r($story3) && p('status,closedReason,duplicateStory') && e('closed,duplicate,5'); // 关闭一个重复了的需求,查看状态 +r($story4) && p('status,closedReason,duplicateStory') && e('~~,~~,『重复需求』不能为空。'); // 关闭一个重复了的需求,但缺少重复的需求的ID,查看状态 \ No newline at end of file