diff --git a/module/story/test/lib/story.unittest.class.php b/module/story/test/lib/story.unittest.class.php index 3480d0ae77..693f0a9681 100644 --- a/module/story/test/lib/story.unittest.class.php +++ b/module/story/test/lib/story.unittest.class.php @@ -1698,4 +1698,20 @@ class storyTest return $method->invoke($this->objectTao, $story, $isShadowProduct); } + + /** + * Test checkCanSplit method. + * + * @param object $story + * @access public + * @return bool + */ + public function checkCanSplitTest(object $story): bool + { + $reflection = new ReflectionClass($this->objectTao); + $method = $reflection->getMethod('checkCanSplit'); + $method->setAccessible(true); + + return $method->invoke($this->objectTao, $story); + } } diff --git a/module/story/test/tao/checkcansplit.php b/module/story/test/tao/checkcansplit.php new file mode 100755 index 0000000000..f3d655caa7 --- /dev/null +++ b/module/story/test/tao/checkcansplit.php @@ -0,0 +1,40 @@ +#!/usr/bin/env php +parent->range('0,0,0,0,2,3,4,4'); +$table->type->range('story,story,story,story,story,requirement,story,story'); +$table->deleted->range('0,0,0,0,0,0,0,1'); +$table->gen(8); + +// 3. 用户登录(选择合适角色) +su('admin'); + +// 4. 创建测试实例(变量名与模块名一致) +$storyTest = new storyTest(); + +// 5. 🔴 强制要求:必须包含至少5个测试步骤 +r($storyTest->checkCanSplitTest((object)array('id' => 1, 'type' => 'story'))) && p() && e('1'); // 步骤1:正常需求无子需求 +r($storyTest->checkCanSplitTest((object)array('id' => 2, 'type' => 'story'))) && p() && e('0'); // 步骤2:需求已有相同类型子需求 +r($storyTest->checkCanSplitTest((object)array('id' => 3, 'type' => 'story'))) && p() && e('1'); // 步骤3:需求有不同类型子需求 +r($storyTest->checkCanSplitTest((object)array('id' => 4, 'type' => 'story'))) && p() && e('0'); // 步骤4:需求有未删除和已删除的子需求 +r($storyTest->checkCanSplitTest((object)array('id' => 999, 'type' => 'story'))) && p() && e('1'); // 步骤5:需求ID不存在 \ No newline at end of file diff --git a/module/story/test/tao/yaml/story_checkcansplit.yaml b/module/story/test/tao/yaml/story_checkcansplit.yaml new file mode 100644 index 0000000000..b14f5e1794 --- /dev/null +++ b/module/story/test/tao/yaml/story_checkcansplit.yaml @@ -0,0 +1,98 @@ +--- +title: checkCanSplit方法测试数据 +desc: 测试需求是否可以拆分的数据配置 +author: Claude +version: 1.0 + +fields: +- field: id + note: 需求ID + range: 1-8 + +- field: vision + note: 产品版本 + range: 'rnd' + +- field: parent + note: 父需求ID + range: '0,0,0,0,2,3,4,0' + +- field: isParent + note: 是否父需求 + range: '0' + +- field: root + note: 根需求ID + range: '0' + +- field: product + note: 所属产品 + range: '1' + +- field: branch + note: 分支 + range: '0' + +- field: module + note: 所属模块 + range: '0' + +- field: title + note: 需求标题 + range: '需求1,需求2,需求3,需求4,子需求1,子需求2,不同类型子需求,删除的子需求' + +- field: type + note: 需求类型 + range: 'story,story,story,story,story,requirement,story,story' + +- field: category + note: 需求分类 + range: 'feature' + +- field: pri + note: 优先级 + range: '3' + +- field: estimate + note: 预估工时 + range: '0' + +- field: status + note: 需求状态 + range: 'active' + +- field: stage + note: 需求阶段 + range: 'wait' + +- field: openedBy + note: 由谁创建 + range: 'admin' + +- field: openedDate + note: 创建时间 + range: '2024-01-01 00:00:00' + +- field: assignedTo + note: 指派给 + range: '' + +- field: assignedDate + note: 指派时间 + range: '' + +- field: lastEditedBy + note: 最后编辑者 + range: 'admin' + +- field: lastEditedDate + note: 最后编辑时间 + range: '2024-01-01 00:00:00' + +- field: version + note: 版本号 + range: '1' + +- field: deleted + note: 是否删除 + range: '0,0,0,0,0,0,0,1' \ No newline at end of file