+ [misc] Add unit tests for taskZen::getParentEstStartedAndDeadline() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -7,38 +7,36 @@ title=测试 taskZen::getParentEstStartedAndDeadline();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 步骤1:正常情况返回数量 @2
|
||||
- 步骤2:空数组返回数量 @0
|
||||
- 步骤3:不存在ID返回数量 @0
|
||||
- 步骤4:验证父任务1开始时间第1条的estStarted属性 @2024-01-01
|
||||
- 步骤5:验证父任务4截止时间第4条的deadline属性 @2024-02-28
|
||||
- 执行taskTest模块的getParentEstStartedAndDeadlineTest方法,参数是array 第1条的estStarted属性 @2024-01-01
|
||||
- 执行taskTest模块的getParentEstStartedAndDeadlineTest方法,参数是array 第999条的estStarted属性 @~~
|
||||
- 执行taskTest模块的getParentEstStartedAndDeadlineTest方法,参数是array @0
|
||||
- 执行taskTest模块的getParentEstStartedAndDeadlineTest方法,参数是array 第1条的estStarted属性 @2024-01-01
|
||||
- 执行taskTest模块的getParentEstStartedAndDeadlineTest方法,参数是array 第7条的estStarted属性 @2024-03-01
|
||||
|
||||
*/
|
||||
|
||||
// 1. 导入依赖(路径固定,不可修改)
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/taskzen.unittest.class.php';
|
||||
|
||||
// 2. 直接插入测试数据
|
||||
zendata('task')->gen(0);
|
||||
|
||||
global $tester;
|
||||
$tester->dao->exec("TRUNCATE TABLE zt_task");
|
||||
$tester->dao->exec("INSERT INTO zt_task (id, parent, path, project, execution, name, type, status, estStarted, deadline) VALUES
|
||||
(1, 0, ',1,', 1, 1, '父任务1', 'devel', 'wait', '2024-01-01', '2024-01-31'),
|
||||
(2, 1, ',1,2,', 1, 1, '子任务1-1', 'devel', 'doing', '0000-00-00', '2024-01-15'),
|
||||
(3, 1, ',1,3,', 1, 1, '子任务1-2', 'devel', 'done', '2024-01-03', '0000-00-00'),
|
||||
(4, 0, ',4,', 1, 1, '父任务2', 'test', 'wait', '2024-02-01', '2024-02-28'),
|
||||
(5, 4, ',4,5,', 1, 1, '子任务2-1', 'test', 'doing', '0000-00-00', '2024-02-15'),
|
||||
(6, 4, ',4,6,', 1, 1, '子任务2-2', 'test', 'done', '2024-02-03', '0000-00-00')");
|
||||
$tester->dao->exec("
|
||||
INSERT INTO " . TABLE_TASK . "
|
||||
(id, parent, project, execution, name, path, estStarted, deadline, status, deleted) VALUES
|
||||
(1, 0, 1, 1, '父任务1', '1', '2024-01-01', '2024-01-31', 'wait', '0'),
|
||||
(2, 0, 1, 1, '父任务2', '2', '2024-01-15', '2024-02-15', 'wait', '0'),
|
||||
(3, 1, 1, 1, '子任务1-1', '1,3', '0000-00-00', '0000-00-00', 'wait', '0'),
|
||||
(7, 0, 1, 1, '父任务7', '7', '2024-03-01', '2024-03-31', 'wait', '0'),
|
||||
(999, 0, 1, 1, '测试任务', '999', '0000-00-00', '0000-00-00', 'wait', '0')
|
||||
");
|
||||
|
||||
// 3. 用户登录
|
||||
su('admin');
|
||||
|
||||
// 4. 创建测试实例
|
||||
$taskTest = new taskZenTest();
|
||||
|
||||
// 5. 必须包含至少5个测试步骤
|
||||
r(count($taskTest->getParentEstStartedAndDeadlineTest(array(1, 4)))) && p() && e('2'); // 步骤1:正常情况返回数量
|
||||
r(count($taskTest->getParentEstStartedAndDeadlineTest(array()))) && p() && e('0'); // 步骤2:空数组返回数量
|
||||
r(count($taskTest->getParentEstStartedAndDeadlineTest(array(999, 1000)))) && p() && e('0'); // 步骤3:不存在ID返回数量
|
||||
r($taskTest->getParentEstStartedAndDeadlineTest(array(1))) && p('1:estStarted') && e('2024-01-01'); // 步骤4:验证父任务1开始时间
|
||||
r($taskTest->getParentEstStartedAndDeadlineTest(array(4))) && p('4:deadline') && e('2024-02-28'); // 步骤5:验证父任务4截止时间
|
||||
r($taskTest->getParentEstStartedAndDeadlineTest(array(1))) && p('1:estStarted') && e('2024-01-01');
|
||||
r($taskTest->getParentEstStartedAndDeadlineTest(array(999))) && p('999:estStarted') && e('~~');
|
||||
r($taskTest->getParentEstStartedAndDeadlineTest(array())) && p() && e('0');
|
||||
r($taskTest->getParentEstStartedAndDeadlineTest(array(1, 2))) && p('1:estStarted') && e('2024-01-01');
|
||||
r($taskTest->getParentEstStartedAndDeadlineTest(array(7))) && p('7:estStarted') && e('2024-03-01');
|
||||
Reference in New Issue
Block a user