From 5cdaa34b3b6dab284f3dd3efa6f8315a87bf7c19 Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 18 Sep 2025 15:32:33 +0800 Subject: [PATCH] + [misc] Add unit tests for taskZen::getParentEstStartedAndDeadline() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../zen/getparentestStartedanddeadline.php | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/module/task/test/zen/getparentestStartedanddeadline.php b/module/task/test/zen/getparentestStartedanddeadline.php index 17b5bc0457..d09c9d7c79 100755 --- a/module/task/test/zen/getparentestStartedanddeadline.php +++ b/module/task/test/zen/getparentestStartedanddeadline.php @@ -7,11 +7,11 @@ title=测试 taskZen::getParentEstStartedAndDeadline(); timeout=0 cid=0 -- 步骤1:正常父任务ID列表数量 @2 -- 步骤2:空父任务ID列表数量 @0 -- 步骤3:不存在的父任务ID数量 @0 -- 步骤4:混合有效和无效ID数量 @1 -- 步骤5:验证返回的开始时间第1条的estStarted属性 @2024-01-01 +- 步骤1:正常情况返回数量 @2 +- 步骤2:空数组返回数量 @0 +- 步骤3:不存在ID返回数量 @0 +- 步骤4:验证父任务1开始时间第1条的estStarted属性 @2024-01-01 +- 步骤5:验证父任务4截止时间第4条的deadline属性 @2024-02-28 */ @@ -19,25 +19,26 @@ cid=0 include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/lib/taskzen.unittest.class.php'; -// 2. 直接使用SQL插入测试数据 +// 2. 直接插入测试数据 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-02-01'), -(2, 1, ',1,2,', 1, 1, '子任务1', 'devel', 'doing', '2024-01-02', '2024-02-02'), -(3, 1, ',1,3,', 1, 1, '子任务2', 'devel', 'doing', '2024-01-03', '2024-02-03'), -(4, 0, ',4,', 1, 1, '父任务2', 'test', 'wait', '2024-01-04', '2024-02-04'), -(5, 4, ',4,5,', 1, 1, '子任务3', 'test', 'done', '2024-01-05', '2024-02-05')"); +(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')"); // 3. 用户登录 su('admin'); // 4. 创建测试实例 -$taskZenTest = new taskZenTest(); +$taskTest = new taskZenTest(); -// 5. 测试步骤:必须包含至少5个测试步骤 -r(count($taskZenTest->getParentEstStartedAndDeadlineTest(array(1, 4)))) && p() && e('2'); // 步骤1:正常父任务ID列表数量 -r(count($taskZenTest->getParentEstStartedAndDeadlineTest(array()))) && p() && e('0'); // 步骤2:空父任务ID列表数量 -r(count($taskZenTest->getParentEstStartedAndDeadlineTest(array(999, 1000)))) && p() && e('0'); // 步骤3:不存在的父任务ID数量 -r(count($taskZenTest->getParentEstStartedAndDeadlineTest(array(1, 999)))) && p() && e('1'); // 步骤4:混合有效和无效ID数量 -r($taskZenTest->getParentEstStartedAndDeadlineTest(array(1))) && p('1:estStarted') && e('2024-01-01'); // 步骤5:验证返回的开始时间 \ No newline at end of file +// 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截止时间 \ No newline at end of file