* Refactor personnelModel::getInvolvedExecutions, and modify its unit test.

This commit is contained in:
liumengyi
2023-12-06 09:38:41 +08:00
parent ec29a13e47
commit 53bef3f16f
3 changed files with 12 additions and 9 deletions
+5 -4
View File
@@ -313,19 +313,20 @@ class personnelModel extends model
}
/**
* 获取项目下的迭代或阶段。
* Gets the iteration or phase under the project.
*
* @param object $projects
* @param array $projects
* @access public
* @return array
*/
public function getInvolvedExecutions($projects)
public function getInvolvedExecutions(array $projects): array
{
$executions = $this->dao->select('id')->from(TABLE_PROJECT)
$executions = $this->dao->select('id,id')->from(TABLE_PROJECT)
->where('type')->in('stage,sprint')
->andWhere('project')->in(array_keys($projects))
->andWhere('deleted')->eq('0')
->fetchPairs('id');
->fetchPairs();
return $this->dao->select('account, count(root) as executions')->from(TABLE_TEAM)
->where('root')->in(array_keys($executions))
@@ -1,5 +1,6 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/personnel.class.php';
@@ -20,7 +21,7 @@ pid=1
$personnel = new personnelTest('admin');
$project = array(array(11, 12), 10000);
$project = array(array(11, 12), array(10000));
$result1 = count($personnel->getInvolvedExecutionsTest($project[0]));
$result2 = $personnel->getInvolvedExecutionsTest($project[0]);
+5 -4
View File
@@ -151,16 +151,17 @@ class personnelTest
}
/**
* Get involved executions test
* 测试获取项目下的迭代或阶段。
* Test get the iteration or phase under the project.
*
* @param array $projectID
* @param array $projects
* @access public
* @return array
*/
public function getInvolvedExecutionsTest($projectID)
public function getInvolvedExecutionsTest(array $projects): array
{
global $tester;
$project = $tester->dao->select('id')->from(TABLE_PROJECT)->where('id')->in($projectID)->fetchall('id');
$project = $tester->dao->select('id')->from(TABLE_PROJECT)->where('id')->in($projects)->fetchAll('id');
$objects = $this->objectModel->getInvolvedExecutions($project);
if(dao::isError()) return dao::getError();