+ [misc] Add unit tests for storyTao::checkCanSplit() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-15 15:09:45 +08:00
co-authored by Claude
parent 319cf2a8f3
commit 30ebd3150a
3 changed files with 154 additions and 0 deletions
@@ -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);
}
}
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env php
<?php
/**
title=测试 storyTao::checkCanSplit();
timeout=0
cid=0
- 步骤1:正常需求无子需求 @1
- 步骤2:需求已有相同类型子需求 @0
- 步骤3:需求有不同类型子需求 @1
- 步骤4:需求有未删除和已删除的子需求 @0
- 步骤5:需求ID不存在 @1
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/story.unittest.class.php';
// 2. zendata数据准备(根据需要配置)
$table = zenData('story');
$table->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不存在
@@ -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'