From 88bbd7c768d8936fa0bfd01a449608c970721b8b Mon Sep 17 00:00:00 2001 From: liugang Date: Wed, 10 Sep 2025 14:09:55 +0800 Subject: [PATCH] + [misc] Add unit tests for tutorialModel::getStoryByID() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../test/lib/tutorial.unittest.class.php | 16 +++++++ module/tutorial/test/model/getstorybyid.php | 48 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100755 module/tutorial/test/model/getstorybyid.php diff --git a/module/tutorial/test/lib/tutorial.unittest.class.php b/module/tutorial/test/lib/tutorial.unittest.class.php index b29e15aaf5..d0738b0d5c 100644 --- a/module/tutorial/test/lib/tutorial.unittest.class.php +++ b/module/tutorial/test/lib/tutorial.unittest.class.php @@ -329,4 +329,20 @@ class tutorialTest return $result; } + + /** + * 测试根据需求ID获取需求详情。 + * Test get story by ID. + * + * @param int $storyID + * @access public + * @return object + */ + public function getStoryByIDTest(int $storyID): object + { + $result = $this->objectModel->getStoryByID($storyID); + if(dao::isError()) return dao::getError(); + + return $result; + } } diff --git a/module/tutorial/test/model/getstorybyid.php b/module/tutorial/test/model/getstorybyid.php new file mode 100755 index 0000000000..268354e77a --- /dev/null +++ b/module/tutorial/test/model/getstorybyid.php @@ -0,0 +1,48 @@ +#!/usr/bin/env php +getStoryByIDTest(1)) && p('id,type,title') && e('1,epic,Test epic'); // 步骤1:获取业务需求 +r($tutorialTest->getStoryByIDTest(2)) && p('id,type,title') && e('2,requirement,Test requirement'); // 步骤2:获取用户需求 +r($tutorialTest->getStoryByIDTest(3)) && p('id,type,title') && e('3,story,Test active story'); // 步骤3:获取研发需求 +r($tutorialTest->getStoryByIDTest(999)) && p('id,type,title') && e('3,story,Test active story'); // 步骤4:获取不存在的需求 +r($tutorialTest->getStoryByIDTest(0)) && p('id,type,title') && e('3,story,Test active story'); // 步骤5:获取边界值需求 \ No newline at end of file