+ [misc] Add unit tests for convertModel::getJiraData() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -88,4 +88,22 @@ class convertTest
|
||||
return 'exception: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getJiraData method.
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $module
|
||||
* @param int $lastID
|
||||
* @param int $limit
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function getJiraDataTest($method = null, $module = null, $lastID = 0, $limit = 0)
|
||||
{
|
||||
$result = $this->objectModel->getJiraData($method, $module, $lastID, $limit);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 convertModel::getJiraData();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 步骤1:使用file方法获取user模块数据,文件不存在返回空数组显示为0 @0
|
||||
- 步骤2:使用file方法获取issue模块数据,文件不存在返回空数组显示为0 @0
|
||||
- 步骤3:使用无效方法获取数据,调用file方法返回空数组显示为0 @0
|
||||
- 步骤4:获取不存在的模块数据,返回空数组显示为0 @0
|
||||
- 步骤5:使用限制参数获取数据,返回空数组显示为0 @0
|
||||
|
||||
*/
|
||||
|
||||
// 1. 导入依赖(路径固定,不可修改)
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/convert.unittest.class.php';
|
||||
|
||||
// 2. 用户登录(选择合适角色)
|
||||
su('admin');
|
||||
|
||||
// 3. 设置测试环境(模拟session数据)
|
||||
global $app;
|
||||
$app->session->jiraDB = 'test_jira_db';
|
||||
$app->session->jiraMethod = 'file';
|
||||
|
||||
// 4. 创建测试实例(变量名与模块名一致)
|
||||
$convertTest = new convertTest();
|
||||
|
||||
// 5. 🔴 强制要求:必须包含至少5个测试步骤
|
||||
r($convertTest->getJiraDataTest('file', 'user', 0, 0)) && p() && e('0'); // 步骤1:使用file方法获取user模块数据,文件不存在返回空数组显示为0
|
||||
r($convertTest->getJiraDataTest('file', 'issue', 0, 0)) && p() && e('0'); // 步骤2:使用file方法获取issue模块数据,文件不存在返回空数组显示为0
|
||||
r($convertTest->getJiraDataTest('invalid', 'user', 0, 0)) && p() && e('0'); // 步骤3:使用无效方法获取数据,调用file方法返回空数组显示为0
|
||||
r($convertTest->getJiraDataTest('file', 'nonexistent', 0, 0)) && p() && e('0'); // 步骤4:获取不存在的模块数据,返回空数组显示为0
|
||||
r($convertTest->getJiraDataTest('file', 'user', 0, 5)) && p() && e('0'); // 步骤5:使用限制参数获取数据,返回空数组显示为0
|
||||
Reference in New Issue
Block a user