+ [misc] Add unit tests for projectZen::removeAssociatedExecutions() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -299,4 +299,37 @@ class projectzenTest
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test removeAssociatedExecutions method.
|
||||
*
|
||||
* @param array $executionIdList
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function removeAssociatedExecutionsTest($executionIdList = array())
|
||||
{
|
||||
try
|
||||
{
|
||||
global $tester;
|
||||
|
||||
// 初始化必要的模型和依赖
|
||||
if(!isset($this->objectZen->project)) $this->objectZen->project = $this->objectModel;
|
||||
|
||||
$reflection = new ReflectionClass($this->objectZen);
|
||||
$method = $reflection->getMethod('removeAssociatedExecutions');
|
||||
$method->setAccessible(true);
|
||||
|
||||
// 调用方法
|
||||
$method->invoke($this->objectZen, $executionIdList);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return 'success';
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 projectZen::removeAssociatedExecutions();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 步骤1:正常删除单个执行 @success
|
||||
- 步骤2:正常删除多个执行 @success
|
||||
- 步骤3:删除空执行列表 @success
|
||||
- 步骤4:删除不存在的执行 @success
|
||||
- 步骤5:删除包含多个执行的列表 @success
|
||||
|
||||
*/
|
||||
|
||||
// 1. 导入依赖(路径固定,不可修改)
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/projectzen.unittest.class.php';
|
||||
|
||||
// 2. zendata数据准备
|
||||
$execution = zenData('project');
|
||||
$execution->id->range('101-120');
|
||||
$execution->type->range('sprint{10}');
|
||||
$execution->name->range('执行1,执行2,执行3,执行4,执行5,执行6,执行7,执行8,执行9,执行10');
|
||||
$execution->status->range('wait{3},doing{4},closed{3}');
|
||||
$execution->parent->range('1{5},2{5}');
|
||||
$execution->gen(10);
|
||||
|
||||
$action = zenData('action');
|
||||
$action->id->range('1-100');
|
||||
$action->objectType->range('execution{50}');
|
||||
$action->objectID->range('101-120');
|
||||
$action->action->range('opened{25},started{15},deleted{10}');
|
||||
$action->gen(50);
|
||||
|
||||
// 3. 用户登录
|
||||
su('admin');
|
||||
|
||||
// 4. 创建测试实例
|
||||
$projectzenTest = new projectzenTest();
|
||||
|
||||
// 5. 强制要求:必须包含至少5个测试步骤
|
||||
r($projectzenTest->removeAssociatedExecutionsTest(array(101 => 101))) && p() && e('success'); // 步骤1:正常删除单个执行
|
||||
r($projectzenTest->removeAssociatedExecutionsTest(array(102 => 102, 103 => 103))) && p() && e('success'); // 步骤2:正常删除多个执行
|
||||
r($projectzenTest->removeAssociatedExecutionsTest(array())) && p() && e('success'); // 步骤3:删除空执行列表
|
||||
r($projectzenTest->removeAssociatedExecutionsTest(array(999 => 999))) && p() && e('success'); // 步骤4:删除不存在的执行
|
||||
r($projectzenTest->removeAssociatedExecutionsTest(array(104 => 104, 105 => 105))) && p() && e('success'); // 步骤5:删除包含多个执行的列表
|
||||
Reference in New Issue
Block a user