* [misc] Enhance unit tests for releaseModel::getBugList() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-25 09:16:28 +08:00
co-authored by Claude
parent aa111e4854
commit 4925254ccf
2 changed files with 48 additions and 9 deletions
@@ -715,4 +715,22 @@ class releaseTest
return $result;
}
/**
* Test getBugList method.
*
* @param string $bugIdList
* @param string $orderBy
* @param object $pager
* @param string $type
* @access public
* @return array
*/
public function getBugListTest(string $bugIdList, string $orderBy = '', ?object $pager = null, string $type = 'linked'): array
{
$result = $this->objectModel->getBugList($bugIdList, $orderBy, $pager, $type);
if(dao::isError()) return dao::getError();
return $result;
}
}
+30 -9
View File
@@ -1,23 +1,44 @@
#!/usr/bin/env php
<?php
/**
title=测试 buildModel->getBugList();
title=测试 releaseModel::getBugList();
timeout=0
cid=1
cid=0
- 步骤1:测试传入空bugIdList @0
- 步骤2:测试传入有效bugIdList获取bug列表第4条的title属性 @Bug5
- 步骤3:测试带orderBy参数的查询第0条的id属性 @3
- 步骤4:测试type参数为left的查询第2条的title属性 @Bug3
- 步骤5:测试不存在的bugIdList查询 @0
- 步骤6:测试单个bugId查询第0条的title属性 @Bug1
- 步骤7:测试大量bugId查询返回的记录数量 @10
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/release.unittest.class.php';
$bug = zenData('bug');
$bug->id->range('1-20');
$bug->product->range('1-5');
$bug->title->range('Bug1,Bug2,Bug3,Bug4,Bug5,Bug6,Bug7,Bug8,Bug9,Bug10,Bug11,Bug12,Bug13,Bug14,Bug15,Bug16,Bug17,Bug18,Bug19,Bug20');
$bug->severity->range('1-4');
$bug->status->range('active{5},resolved{5},closed{5},active{5}');
$bug->openedBy->range('admin,user1,user2');
$bug->deleted->range('0');
$bug->gen(20);
zenData('bug')->loadYaml('bug')->gen(10);
zenData('user')->gen(5);
su('admin');
$bugs = array('', '1,2,3,4,5', '11,12,13,14,15');
$releaseTest = new releaseTest();
global $tester;
$tester->loadModel('release');
r($tester->release->getBugList($bugs[0])) && p() && e('0'); // 测试传入空数组获取bug列表数据
r($tester->release->getBugList($bugs[1])) && p('4:title') && e('Bug5'); // 测试传入bugId列表获取bug列表数据
r($tester->release->getBugList($bugs[2])) && p() && e('0'); // 测试传入不存在bugId列表获取bug列表数据
r($releaseTest->getBugListTest('')) && p() && e('0'); // 步骤1:测试传入空bugIdList
r($releaseTest->getBugListTest('1,2,3,4,5')) && p('4:title') && e('Bug5'); // 步骤2:测试传入有效bugIdList获取bug列表
r($releaseTest->getBugListTest('1,2,3', 'id_desc')) && p('0:id') && e('3'); // 步骤3:测试带orderBy参数的查询
r($releaseTest->getBugListTest('1,2,3', '', null, 'left')) && p('2:title') && e('Bug3'); // 步骤4:测试type参数为left的查询
r($releaseTest->getBugListTest('100,200,300')) && p() && e('0'); // 步骤5:测试不存在的bugIdList查询
r($releaseTest->getBugListTest('1')) && p('0:title') && e('Bug1'); // 步骤6:测试单个bugId查询
r(count($releaseTest->getBugListTest('1,2,3,4,5,6,7,8,9,10'))) && p() && e('10'); // 步骤7:测试大量bugId查询返回的记录数量