diff --git a/module/build/model.php b/module/build/model.php index 747028a9a8..896f7bc644 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -53,17 +53,18 @@ class buildModel extends model } /** + * 通过项目ID获取版本信息。 * Get builds of a project. * * @param int $projectID * @param string $type - * @param int $param + * @param string $param * @param string $orderBy * @param object $pager * @access public * @return array */ - public function getProjectBuilds($projectID = 0, $type = 'all', $param = 0, $orderBy = 't1.date_desc,t1.id_desc', $pager = null) + public function getProjectBuilds(int $projectID = 0, string $type = 'all', string $param = '', string $orderBy = 't1.date_desc,t1.id_desc', object $pager = null): array { $builds = $this->dao->select('t1.*, t2.name as productName') ->from(TABLE_BUILD)->alias('t1') @@ -71,18 +72,17 @@ class buildModel extends model ->where('t1.deleted')->eq(0) ->andWhere('t1.project')->ne(0) ->beginIF($projectID)->andWhere('t1.project')->eq((int)$projectID)->fi() - ->beginIF($type == 'product' and $param)->andWhere('t1.product')->eq($param)->fi() + ->beginIF($type == 'product' && $param)->andWhere('t1.product')->eq((int)$param)->fi() ->beginIF($type == 'bysearch')->andWhere($param)->fi() ->beginIF($type == 'review')->andWhere("FIND_IN_SET('{$this->app->user->account}', t1.reviewers)")->fi() ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); - $this->loadModel('build'); $executionIdList = array(); foreach($builds as $build) { - $build->builds = $this->build->getByList(explode(',', $build->builds)); + $build->builds = $this->getByList(explode(',', $build->builds)); if(!empty($build->builds)) { foreach($build->builds as $child) @@ -107,6 +107,7 @@ class buildModel extends model } /** + * 根据搜索条件获取项目版本。 * Get builds of a project by search. * * @param int $projectID @@ -116,7 +117,7 @@ class buildModel extends model * @access public * @return array */ - public function getProjectBuildsBySearch($projectID, $queryID, $orderBy = 't1.date_desc,t1.id_desc', $pager = null) + public function getProjectBuildsBySearch(int $projectID, int $queryID, string $orderBy = 't1.date_desc,t1.id_desc', object $pager = null): array { /* If there are saved query conditions, reset the session. */ if((int)$queryID) @@ -142,7 +143,7 @@ class buildModel extends model } } - return $this->getProjectBuilds($projectID, 'bysearch', $buildQuery, $orderBy, $pager); + return $this->getProjectBuilds($projectID, 'bysearch', (string)$buildQuery, $orderBy, $pager); } /** diff --git a/module/build/test/build.class.php b/module/build/test/build.class.php index 8c0c6e27de..6741930aae 100644 --- a/module/build/test/build.class.php +++ b/module/build/test/build.class.php @@ -46,16 +46,16 @@ class buildTest /** * function getProjectBuilds test by build * - * @param int $count - * @param int $projectID - * @param string $type - * @param string $param - * @param string $orderBy - * @param string $pager + * @param int $count + * @param int $projectID + * @param string $type + * @param string $param + * @param string $orderBy + * @param string $pager * @access public - * @return array + * @return array|int */ - public function getProjectBuildsTest($count, $projectID, $type = 'all', $param = 0, $orderBy = 't1.date_desc,t1.id_desc', $pager = null) + public function getProjectBuildsTest(int $count, int $projectID, string $type = 'all', string $param = '', string $orderBy = 't1.date_desc,t1.id_desc', object $pager = null): array|int { $objects = $this->objectModel->getProjectBuilds($projectID, $type, $param, $orderBy, $pager); @@ -68,13 +68,13 @@ class buildTest /** * function getProjectBuildsBySearch test by build * - * @param string $count - * @param string $projectID - * @param string $queryID + * @param int $count + * @param int $projectID + * @param int $queryID * @access public - * @return array + * @return array|int */ - public function getProjectBuildsBySearchTest($count, $projectID, $queryID) + public function getProjectBuildsBySearchTest(int $count, int $projectID, int $queryID): array|int { $objects = $this->objectModel->getProjectBuildsBySearch($projectID, $queryID); diff --git a/module/build/test/model/getprojectbuilds.php b/module/build/test/model/getprojectbuilds.php index 0623f5b50f..e092d36b3a 100755 --- a/module/build/test/model/getprojectbuilds.php +++ b/module/build/test/model/getprojectbuilds.php @@ -1,40 +1,33 @@ #!/usr/bin/env php getProjectBuilds(); +timeout=0 cid=1 -pid=1 - -全部项目版本查询 >> 11,项目版本版本1 -单独项目版本查询 >> 17,项目版本版本7 -不存在项目版本查询 >> 0 -根据产品查询版本 >> 17,项目版本版本7 -根据查询条件查询版本 >> 17,项目版本版本7 -无查询条件查询版本 >> 17,项目版本版本7 -全部项目版本查询统计 >> 10 -单独项目版本查询统计 >> 1 -无查询条件查询版本统计 >> 10 */ -$count = array('0', '1'); -$projectIDList = array('0', '17', '57'); +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/build.class.php'; + +zdTable('build')->config('build')->gen(20); +zdTable('project')->config('execution')->gen(30); +zdTable('product')->config('product')->gen(10); +su('admin'); + +$count = array(0, 1); +$projectIDList = array(0, 17, 7); $type = array('all', 'product', 'bysearch', 'test'); -$parm = array(7, "t1.name = '项目版本版本7'", "test"); +$parm = array(7, "t1.name = '版本7'", "test"); $build = new buildTest(); - -r($build->getProjectBuildsTest($count[0], $projectIDList[0], $type[0])) && p('1:project,name') && e('11,项目版本版本1'); //全部项目版本查询 -r($build->getProjectBuildsTest($count[0], $projectIDList[1], $type[0])) && p('7:project,name') && e('17,项目版本版本7'); //单独项目版本查询 -r($build->getProjectBuildsTest($count[0], $projectIDList[2], $type[0])) && p() && e('0'); //不存在项目版本查询 -r($build->getProjectBuildsTest($count[0], $projectIDList[0], $type[1], $parm[0])) && p('7:project,name') && e('17,项目版本版本7'); //根据产品查询版本 -r($build->getProjectBuildsTest($count[0], $projectIDList[1], $type[2], $parm[1])) && p('7:project,name') && e('17,项目版本版本7'); //根据查询条件查询版本 -r($build->getProjectBuildsTest($count[0], $projectIDList[0], $type[3], $parm[2])) && p('7:project,name') && e('17,项目版本版本7'); //无查询条件查询版本 -r($build->getProjectBuildsTest($count[1], $projectIDList[0], $type[0])) && p() && e('10'); //全部项目版本查询统计 -r($build->getProjectBuildsTest($count[1], $projectIDList[1], $type[0])) && p() && e('1'); //单独项目版本查询统计 -r($build->getProjectBuildsTest($count[1], $projectIDList[0], $type[3], $parm[2])) && p() && e('10'); //无查询条件查询版本统计 \ No newline at end of file +r($build->getProjectBuildsTest($count[0], $projectIDList[0], $type[0])) && p('1:project,name') && e('11,版本1'); // 全部项目版本查询 +r($build->getProjectBuildsTest($count[0], $projectIDList[1], $type[0])) && p('7') && e('0'); // 单独项目版本查询 +r($build->getProjectBuildsTest($count[0], $projectIDList[2], $type[0])) && p() && e('0'); // 不存在项目版本查询 +r($build->getProjectBuildsTest($count[0], $projectIDList[0], $type[1], $parm[0])) && p('19:project,name') && e('61,版本19'); // 根据产品查询版本 +r($build->getProjectBuildsTest($count[0], $projectIDList[1], $type[2], $parm[1])) && p('7') && e('0'); // 根据查询条件查询版本 +r($build->getProjectBuildsTest($count[0], $projectIDList[0], $type[3], $parm[2])) && p('7:project,name') && e('61,版本7'); // 无查询条件查询版本 +r($build->getProjectBuildsTest($count[1], $projectIDList[0], $type[0])) && p() && e('20'); // 全部项目版本查询统计 +r($build->getProjectBuildsTest($count[1], $projectIDList[1], $type[0])) && p() && e('0'); // 单独项目版本查询统计 +r($build->getProjectBuildsTest($count[1], $projectIDList[0], $type[3], $parm[2])) && p() && e('20'); // 无查询条件查询版本统计 diff --git a/module/build/test/model/getprojectbuildsbysearch.php b/module/build/test/model/getprojectbuildsbysearch.php index 6bd6a0d85e..cd6a61b70e 100755 --- a/module/build/test/model/getprojectbuildsbysearch.php +++ b/module/build/test/model/getprojectbuildsbysearch.php @@ -1,41 +1,29 @@ #!/usr/bin/env php getProjectBuildsBySearch(); +timeout=0 cid=1 -pid=1 - -项目id为0查询 >> 18,项目版本版本8 -正常项目查询 >> 17,项目版本版本7 -项目id为空查询 >> 19,项目版本版本9 -搜索条件id为空查询 >> 16,项目版本版本6 -项目id为0查询统计 >> 10 -正常项目查询统计 >> 1 -项目id为空查询统计 >> 10 -搜索条件id为空查询统计 >> 10 -查询条件查询 >> 17,项目版本版本7 -查询条件查询统计 >> 1 */ -$projectIDList = array('0', '17', ''); -$queryIDList = array('0', '4', ''); -$count = array('0', '1'); +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/build.class.php'; + +zdTable('build')->config('build')->gen(20); +zdTable('project')->config('execution')->gen(30); +zdTable('product')->config('product')->gen(10); +su('admin'); + +$projectIDList = array(0, 17); +$queryIDList = array(0, 4); +$count = array(0, 1); $build = new buildTest(); - -r($build->getProjectBuildsBySearchTest($count[0], $projectIDList[0], $queryIDList[0])) && p('8:project,name') && e('18,项目版本版本8');//项目id为0查询 -r($build->getProjectBuildsBySearchTest($count[0], $projectIDList[1], $queryIDList[0])) && p('7:project,name') && e('17,项目版本版本7');//正常项目查询 -r($build->getProjectBuildsBySearchTest($count[0], $projectIDList[2], $queryIDList[0])) && p('9:project,name') && e('19,项目版本版本9');//项目id为空查询 -r($build->getProjectBuildsBySearchTest($count[0], $projectIDList[0], $queryIDList[2])) && p('6:project,name') && e('16,项目版本版本6');//搜索条件id为空查询 -r($build->getProjectBuildsBySearchTest($count[1], $projectIDList[0], $queryIDList[0])) && p() && e('10'); //项目id为0查询统计 -r($build->getProjectBuildsBySearchTest($count[1], $projectIDList[1], $queryIDList[0])) && p() && e('1'); //正常项目查询统计 -r($build->getProjectBuildsBySearchTest($count[1], $projectIDList[2], $queryIDList[0])) && p() && e('10'); //项目id为空查询统计 -r($build->getProjectBuildsBySearchTest($count[1], $projectIDList[0], $queryIDList[2])) && p() && e('10'); //搜索条件id为空查询统计 -r($build->getProjectBuildsBySearchTest($count[0], $projectIDList[0], $queryIDList[1])) && p('7:project,name') && e('17,项目版本版本7');//查询条件查询 -r($build->getProjectBuildsBySearchTest($count[1], $projectIDList[0], $queryIDList[1])) && p() && e('1'); //查询条件查询统计 \ No newline at end of file +r($build->getProjectBuildsBySearchTest($count[0], $projectIDList[0], $queryIDList[0])) && p('8:project,name') && e('100,版本8'); // 项目id为0查询 +r($build->getProjectBuildsBySearchTest($count[0], $projectIDList[1], $queryIDList[0])) && p('7') && e('0'); // 正常项目查询 +r($build->getProjectBuildsBySearchTest($count[1], $projectIDList[0], $queryIDList[0])) && p() && e('20'); // 项目id为0查询统计 +r($build->getProjectBuildsBySearchTest($count[1], $projectIDList[1], $queryIDList[0])) && p() && e('0'); // 正常项目查询统计 +r($build->getProjectBuildsBySearchTest($count[0], $projectIDList[0], $queryIDList[1])) && p('7:project,name') && e('61,版本7'); // 查询条件查询 +r($build->getProjectBuildsBySearchTest($count[1], $projectIDList[0], $queryIDList[1])) && p() && e('20'); // 查询条件查询统计