* Modify unit test of projectreleaseModel::getList.
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
class projectreleaseModel extends model
|
||||
{
|
||||
/**
|
||||
* 获取项目发布列表。
|
||||
* Get list of releases.
|
||||
*
|
||||
* @param int $projectID
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/projectrelease.class.php';
|
||||
|
||||
zdTable('release')->gen(20);
|
||||
zdTable('product')->gen(20);
|
||||
zdTable('user')->gen(1);
|
||||
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
@@ -10,25 +15,17 @@ title=测试 projectreleaseModel->getList();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
查询projectID正常存在,type为all的发布 >> 产品1发布9,normal
|
||||
查询projectID正常存在,type为normal的发布 >> 产品1发布9,normal
|
||||
查询projectID正常存在,type为terminate的发布 >> 0
|
||||
查询projectID正常存在,type为''的发布 >> 0
|
||||
查询projectID正常存在的发布 >> 产品1发布9,normal
|
||||
查询projectID不存在,type为all的发布 >> 0
|
||||
查询projectID为空,type为all的发布 >> 8
|
||||
|
||||
*/
|
||||
|
||||
$projectID = array(11, 1000, '');
|
||||
$projectID = array(11, 1000, 0);
|
||||
$type = array('all', 'normal', 'terminate', '');
|
||||
|
||||
$projectrelease = new projectreleaseTest();
|
||||
|
||||
r($projectrelease->getListTest($projectID[0], $type[0])) && p('0:name,status') && e('产品1发布9,normal'); //查询projectID正常存在,type为all的发布
|
||||
r($projectrelease->getListTest($projectID[0], $type[1])) && p('0:name,status') && e('产品1发布9,normal'); //查询projectID正常存在,type为normal的发布
|
||||
r($projectrelease->getListTest($projectID[0], $type[2])) && p() && e('0'); //查询projectID正常存在,type为terminate的发布
|
||||
r($projectrelease->getListTest($projectID[0], $type[3])) && p() && e('0'); //查询projectID正常存在,type为''的发布
|
||||
r($projectrelease->getListTest($projectID[0])) && p('0:name,status') && e('产品1发布9,normal'); //查询projectID正常存在的发布
|
||||
r($projectrelease->getListTest($projectID[1], $type[0])) && p() && e('0'); //查询projectID不存在,type为all的发布
|
||||
r($projectrelease->getListTest($projectID[2], $type[0])) && p('0:id') && e('8'); //查询projectID为空,type为all的发布
|
||||
r($projectrelease->getListTest($projectID[0], $type[0])) && p() && e('9,19'); // 查询projectID正常存在,type为all的发布
|
||||
r($projectrelease->getListTest($projectID[0], $type[1])) && p() && e('9,19'); // 查询projectID正常存在,type为normal的发布
|
||||
r($projectrelease->getListTest($projectID[0], $type[2])) && p() && e('0'); // 查询projectID正常存在,type为terminate的发布
|
||||
r($projectrelease->getListTest($projectID[0], $type[3])) && p() && e('0'); // 查询projectID正常存在,type为''的发布
|
||||
r($projectrelease->getListTest($projectID[0])) && p() && e('9,19'); // 查询projectID正常存在的发布
|
||||
r($projectrelease->getListTest($projectID[1], $type[0])) && p() && e('0'); // 查询projectID不存在,type为all的发布
|
||||
r($projectrelease->getListTest($projectID[2], $type[0])) && p() && e('8,18'); // 查询projectID为空,type为all的发布
|
||||
|
||||
@@ -8,24 +8,21 @@ class projectreleaseTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list of releases.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getListTest($projectID, $type = 'all')
|
||||
* 测试获取项目发布列表。
|
||||
* Test get list of releases.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return array|string
|
||||
*/
|
||||
public function getListTest(int $projectID, string $type = 'all'): array|string
|
||||
{
|
||||
$objects = $this->objectModel->getList($projectID, $type);
|
||||
|
||||
if(dao::isError())
|
||||
{
|
||||
$error = dao::getError();
|
||||
return $error[0];
|
||||
}
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $objects;
|
||||
return implode(',', array_column($objects, 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user