* [misc] Fix unit tests for storyModel::batchChangeParent() method

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-29 16:42:04 +08:00
co-authored by Claude
parent 66f6aaff13
commit a3403c96c9
+21 -28
View File
@@ -3,39 +3,32 @@
/**
title=测试 storyModel::batchChangeParent();
cid=0
title=- 测试步骤4:自身作为父需求的错误情况 @
timeout=0
cid=1
- 测试步骤1:正常批量更改父需求 >> 期望返回空字符串表示成功
- 测试步骤2:空的故事ID列表输入 >> 期望返回空值
- 测试步骤3:无效的父需求ID >> 期望返回空字符串
- 测试步骤4:自身作为父需求的错误情况 >> 期望返回包含错误信息的字符串
- 测试步骤5:正常的需求层级变更 >> 期望跳过twins需求
- 测试步骤1:正常批量更改父需求 @
- 测试步骤2:空的故事ID列表输入 @~~
- 测试步骤3:无效的父需求ID @
- 测试步骤4:自身作为父需求的错误情况 @#1需求的父需求不能为其本身或其子需求,本次修改已将其忽略。
- 测试步骤5:正常的需求层级变更 @
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/story.unittest.class.php';
$table = zenData('story');
$table->id->range('1-10');
$table->product->range('1');
$table->type->range('story');
$table->grade->range('1{5},2{5}');
$table->parent->range('0{5},1{3},2{2}');
$table->root->range('1-5,1,2,2');
$table->path->range(',1,,2,,3,,4,,5,,1,1,,1,2,,2,2,');
$table->status->range('active');
$table->stage->range('wait');
$table->twins->range('');
$table->gen(10);
su('admin');
$storyTest = new storyTest();
zenData('user')->gen(5);
zenData('product')->gen(5);
zenData('story')->gen(10);
zenData('storygrade')->gen(6);
zenData('storyspec')->gen(10);
r($storyTest->batchChangeParentTest('6,7', 1, 'story')) && p() && e(''); // 测试步骤1:正常批量更改父需求
r($storyTest->batchChangeParentTest('', 1, 'story')) && p() && e('~~'); // 测试步骤2:空的故事ID列表输入
r($storyTest->batchChangeParentTest('8,9', 999, 'story')) && p() && e(''); // 测试步骤3:无效的父需求ID
r($storyTest->batchChangeParentTest('1', 1, 'story')) && p() && e('#1需求的父需求不能为其本身或其子需求,本次修改已将其忽略。'); // 测试步骤4:自身作为父需求的错误情况
r($storyTest->batchChangeParentTest('3,4', 2, 'story')) && p() && e(''); // 测试步骤5:正常的需求层级变更
global $tester;
$tester->loadModel('story');
r($tester->story->batchChangeParent('6,7', 1, 'story')) && p() && e(''); // 测试步骤1:正常批量更改父需求
r($tester->story->batchChangeParent('', 1, 'story')) && p() && e('~~'); // 测试步骤2:空的故事ID列表输入
r($tester->story->batchChangeParent('8,9', 999, 'story')) && p() && e(''); // 测试步骤3:无效的父需求ID
r($tester->story->batchChangeParent('1', 1, 'story')) && p() && e('#1需求的父需求不能为其本身或其子需求,本次修改已将其忽略。'); // 测试步骤4:自身作为父需求的错误情况
r($tester->story->batchChangeParent('3,4', 2, 'story')) && p() && e(''); // 测试步骤5:正常的需求层级变更