znt/module/story/test/model/getidlistwithtask.php

49 lines
1.7 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
/**
title=测试 storyModel::getIdListWithTask();
timeout=0
cid=18538
- 执行101有3个任务关联需求1,2,3 @3
- 执行102有2个任务关联需求1,2 @2
- 执行ID为0返回空数组 @0
- 负数执行ID返回空数组 @0
- 执行103的任务都没有关联需求story=0返回空数组 @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 准备测试数据
$task = zenData('task');
$task->id->range('1-10');
$task->execution->range('101{3},102{2},103{2},999{3}');
$task->story->range('1,2,3,1,2,0,0,4,5,6');
$task->deleted->range('0{8},1{2}');
$task->status->range('wait{4},doing{3},done{3}');
$task->gen(10);
// 用户登录
su('admin');
// 创建测试实例
$storyTest = new storyModelTest();
// 测试步骤1正常情况 - 获取包含关联需求任务的执行的需求ID列表数量
r(count($storyTest->getIdListWithTaskTest(101))) && p() && e('3'); // 执行101有3个任务关联需求1,2,3
// 测试步骤2正常情况 - 获取另一个执行的需求ID列表数量
r(count($storyTest->getIdListWithTaskTest(102))) && p() && e('2'); // 执行102有2个任务关联需求1,2
// 测试步骤3边界值测试 - 无效执行ID0
r(count($storyTest->getIdListWithTaskTest(0))) && p() && e('0'); // 执行ID为0返回空数组
// 测试步骤4边界值测试 - 无效执行ID负数
r(count($storyTest->getIdListWithTaskTest(-1))) && p() && e('0'); // 负数执行ID返回空数组
// 测试步骤5业务规则测试 - 包含story字段为0的任务的执行
r(count($storyTest->getIdListWithTaskTest(103))) && p() && e('0'); // 执行103的任务都没有关联需求story=0返回空数组