+ [misc] Add unit tests for tutorialModel::getStoryByID() 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:06:25 +08:00
co-authored by Claude
parent 5e5ad3972c
commit 88bbd7c768
2 changed files with 64 additions and 0 deletions
@@ -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;
}
}
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env php
<?php
/**
title=测试 tutorialModel::getStoryByID();
timeout=0
cid=0
- 步骤1:获取业务需求
- 属性id @1
- 属性type @epic
- 属性title @Test epic
- 步骤2:获取用户需求
- 属性id @2
- 属性type @requirement
- 属性title @Test requirement
- 步骤3:获取研发需求
- 属性id @3
- 属性type @story
- 属性title @Test active story
- 步骤4:获取不存在的需求
- 属性id @3
- 属性type @story
- 属性title @Test active story
- 步骤5:获取边界值需求
- 属性id @3
- 属性type @story
- 属性title @Test active story
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/tutorial.unittest.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$tutorialTest = new tutorialTest();
// 4. 强制要求:必须包含至少5个测试步骤
r($tutorialTest->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:获取边界值需求