* Add comments for bug::getLinkedExecutionByIdList, and add its unit test.
This commit is contained in:
+12
-5
@@ -1162,25 +1162,32 @@ class bugModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过版本 id 列表获取版本关联的执行。
|
||||
* Get linked execution by build id list.
|
||||
*
|
||||
* @param string $buildIdList
|
||||
* @param array $buildIdList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getLinkedExecutionByIdList($buildIdList)
|
||||
public function getLinkedExecutionByIdList(array $buildIdList): array
|
||||
{
|
||||
/* Get information of builds. */
|
||||
$builds = $this->dao->select('id,execution,builds')->from(TABLE_BUILD)->where('id')->in($buildIdList)->fetchAll('id');
|
||||
|
||||
$executionIdList = array();
|
||||
$linkedBuildIdList = array();
|
||||
foreach($builds as $build)
|
||||
{
|
||||
/* 如果版本的builds字段不为空,将版本的builds追加到linkedBuildIdList数组。 */
|
||||
/* If build builds is not empty, append build builds to linkedBuildIdList. */
|
||||
if($build->builds) $linkedBuildIdList = array_merge($linkedBuildIdList, explode(',', $build->builds));
|
||||
|
||||
if(empty($build->execution)) continue;
|
||||
$executionIdList[$build->execution] = $build->execution;
|
||||
/* 如果版本的执行字段不为空,将执行字段追加到executionIdList数组。 */
|
||||
/* If build execution is not empty, append build execution to executionIdList. */
|
||||
if(!empty($build->execution)) $executionIdList[$build->execution] = $build->execution;
|
||||
}
|
||||
|
||||
/* 如果linkedBuildIdList不为空,将关联builds的版本追加到executionIdList数组。 */
|
||||
/* If linkedBuildIdList is not empty, append the execution of the linked builds to executionIdList. */
|
||||
if($linkedBuildIdList)
|
||||
{
|
||||
$linkedBuilds = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->in(array_unique($linkedBuildIdList))->fetchAll('id');
|
||||
|
||||
@@ -1347,4 +1347,31 @@ class bugTest
|
||||
return $build;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试通过版本 id 列表获取版本关联的执行。
|
||||
* Test get linked execution by id list.
|
||||
*
|
||||
* @param string $buildIdList
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getLinkedExecutionByIdListTest(string $buildIdList): array|string
|
||||
{
|
||||
$buildIdList = explode(',', $buildIdList);
|
||||
$array = $this->objectModel->getLinkedExecutionByIdList($buildIdList);
|
||||
|
||||
$idList = '';
|
||||
foreach($array as $execution) $idList .= ',' . $execution;
|
||||
$idList = trim($idList, ',');
|
||||
|
||||
if(dao::isError())
|
||||
{
|
||||
return dao::getError();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $idList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/bug.class.php';
|
||||
|
||||
zdTable('build')->config('build')->gen(100);
|
||||
|
||||
/**
|
||||
|
||||
title=bugModel->getLinkedExecutionByIdList();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
- 测试获取版本ID 1 3 5 的执行 @1,3
|
||||
|
||||
|
||||
- 测试获取版本ID 2 4 6 的执行 @2,4
|
||||
|
||||
|
||||
- 测试获取版本ID 41 51 61 的执行 @39,49,59,2
|
||||
|
||||
|
||||
- 测试获取版本ID 10 30 70 的执行 @8,28,68,2
|
||||
|
||||
|
||||
- 测试获取版本ID 不存在 的执行 @0
|
||||
|
||||
*/
|
||||
|
||||
$builds = array('', '1,3,5', '2,4,6', '41,51,61', '10,30,70', '1000001,100002');
|
||||
|
||||
$bug=new bugTest();
|
||||
r($bug->getLinkedExecutionByIdListTest($builds[1])) && p() && e('1,3'); // 测试获取版本ID 1 3 5 的执行
|
||||
r($bug->getLinkedExecutionByIdListTest($builds[2])) && p() && e('2,4'); // 测试获取版本ID 2 4 6 的执行
|
||||
r($bug->getLinkedExecutionByIdListTest($builds[3])) && p() && e('39,49,59,2'); // 测试获取版本ID 41 51 61 的执行
|
||||
r($bug->getLinkedExecutionByIdListTest($builds[4])) && p() && e('8,28,68,2'); // 测试获取版本ID 10 30 70 的执行
|
||||
r($bug->getLinkedExecutionByIdListTest($builds[5])) && p() && e('0'); // 测试获取版本ID 不存在 的执行
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php'; su('admin');
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/bug.class.php';
|
||||
|
||||
zdTable('bug')->gen(140);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: zt_build
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: execution
|
||||
range: 0{2},1-90
|
||||
- field: builds
|
||||
fields:
|
||||
- field: build1
|
||||
range: "``{50}, `,`{50}"
|
||||
- field: build2
|
||||
range: "``{50}, 2-100:2{50}"
|
||||
- field: build3
|
||||
range: "``{50}, `,`{50}"
|
||||
- field: build4
|
||||
range: "``{50}, 4-100:2{50}"
|
||||
- field: build5
|
||||
range: "``{50}, `,`{50}"
|
||||
|
||||
Reference in New Issue
Block a user