From 1ba0a13b4eeccad9bfc57f3d5b312367d2a1c7fa Mon Sep 17 00:00:00 2001 From: liugang Date: Wed, 17 Sep 2025 16:52:45 +0800 Subject: [PATCH] + [misc] Add unit tests for storyZen::getAfterCreateLocation() 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/storyzen.unittest.class.php | 25 ++++++++++ .../story/test/zen/getaftercreatelocation.php | 48 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 module/story/test/zen/getaftercreatelocation.php diff --git a/module/story/test/lib/storyzen.unittest.class.php b/module/story/test/lib/storyzen.unittest.class.php index ea30d97b9e..d24222e6bb 100755 --- a/module/story/test/lib/storyzen.unittest.class.php +++ b/module/story/test/lib/storyzen.unittest.class.php @@ -694,4 +694,29 @@ class storyZenTest $result['count'] = count($stories); return $result; } + + /** + * Test getAfterCreateLocation method. + * + * @param int $productID + * @param string $branch + * @param int $objectID + * @param int $storyID + * @param string $storyType + * @param string $extra + * @access public + * @return string + */ + public function getAfterCreateLocationTest(int $productID, string $branch, int $objectID, int $storyID, string $storyType, string $extra = ''): string + { + global $app; + + $method = $this->storyZenTest->getMethod('getAfterCreateLocation'); + $method->setAccessible(true); + + $result = $method->invokeArgs($this->storyZenTest->newInstance(), [$productID, $branch, $objectID, $storyID, $storyType, $extra]); + if(dao::isError()) return dao::getError(); + + return $result; + } } diff --git a/module/story/test/zen/getaftercreatelocation.php b/module/story/test/zen/getaftercreatelocation.php new file mode 100755 index 0000000000..1e85324cbb --- /dev/null +++ b/module/story/test/zen/getaftercreatelocation.php @@ -0,0 +1,48 @@ +#!/usr/bin/env php +id->range('1-10'); +$project->name->range('项目1,项目2,执行1,执行2,项目3,执行3,项目4,执行4,项目5,执行5'); +$project->type->range('project{2},execution{2},project{2},execution{2},project{2}'); +$project->status->range('wait,doing{9}'); +$project->gen(10); + +$product = zenData('product'); +$product->id->range('1-5'); +$product->name->range('产品1,产品2,产品3,产品4,产品5'); +$product->status->range('normal{5}'); +$product->type->range('normal{3},branch{2}'); +$product->gen(5); + +// 3. 用户登录 +su('admin'); + +// 4. 创建测试实例 +$storyZenTest = new storyZenTest(); + +// 5. 测试步骤 +r($storyZenTest->getAfterCreateLocationTest(1, 'all', 0, 1, 'story', '')) && p() && e('product-browse-1-all--0-story-id_desc.html'); // 步骤1:正常产品浏览情况 +r($storyZenTest->getAfterCreateLocationTest(1, 'all', 1, 1, 'story', '')) && p() && e('execution-story-1.html'); // 步骤2:项目执行情况(project类型) +r($storyZenTest->getAfterCreateLocationTest(1, 'all', 3, 1, 'story', '')) && p() && e('execution-story-3.html'); // 步骤3:执行情况(execution类型) +r($storyZenTest->getAfterCreateLocationTest(2, '', 5, 1, 'requirement', '')) && p() && e('execution-story-5.html'); // 步骤4:需求类型情况 +r($storyZenTest->getAfterCreateLocationTest(4, 'all', 0, 1, 'story', '')) && p() && e('product-browse-4-all--0-story-id_desc.html'); // 步骤5:分支产品情况 \ No newline at end of file