diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index ff32927a3a..01ce67d33b 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -1710,37 +1710,33 @@ class executionTest } /** - * function manageMembers test by execution + * 维护执行的团队成员。 + * Manage members of the execution. * - * @param string $executionID - * @param string $count - * @param array $param + * @param int $executionID + * @param int $count + * @param array $params * @access public - * @return array + * @return array|string|int */ - public function manageMembersTest($executionID, $count, $param = array()) + public function manageMembersTest(int $executionID, int $count, array $params = array()): array|string|int { - global $tester; - $tester->dbh->query("delete from zt_team where root = $executionID"); + $this->executionModel->dao->delete()->from(TABLE_TEAM)->where('root')->eq($executionID)->exec(); - $realnames = array(); - $roles = array(); - $days = array(); - $hours = array(); - $accounts = array(); - $limited = array(); + $members = array(); + foreach($params as $key => $valueList) + { + $members[$key] = new stdclass(); + foreach($valueList as $field => $value) + { + $members[$key]->$field = $value; + } + } - $createFields = array('realnames' => $realnames, 'roles' => $roles, 'hours' => $hours, 'accounts' => $accounts, - 'limited' => $limited, 'days' => $days); + $execution = $this->executionModel->getByID($executionID); + $this->executionModel->manageMembers($execution, $members); - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $object = $this->executionModel->manageMembers($executionID); - - unset($_POST); - - $object = $tester->dbh->query("select * from zt_team where root = $executionID")->fetchAll(); + $objects = $this->executionModel->dao->select('*')->from(TABLE_TEAM)->where('root')->eq($executionID)->fetchAll(); if(dao::isError()) { @@ -1749,17 +1745,17 @@ class executionTest } elseif($count == "1") { - return count($object); + return count($objects); } else { - if(empty($object)) + if(empty($objects)) { return '无数据'; } else { - return $object; + return $objects; } } } diff --git a/module/execution/test/model/managemembers.php b/module/execution/test/model/managemembers.php index b55a0284e8..8be0c1b52f 100755 --- a/module/execution/test/model/managemembers.php +++ b/module/execution/test/model/managemembers.php @@ -29,24 +29,22 @@ su('admin'); /** title=测试executionModel->manageMembersTest(); +timeout=0 cid=1 -pid=1 - -团队管理 >> 3,execution,user1 -团队人员管理统计 >> 3 */ -$executionID = '3'; -$realnames = array('用户1', '用户2', 'admin'); +$executionID = 3; +$accounts = array('user1', 'user2', 'admin'); $roles = array('研发', '研发', '研发'); $hours = array('3.0', '6.0', '7.0'); -$accounts = array('user1', 'user2', 'admin'); $limited = array('yes', 'no', 'yes'); $days = array('17', '27', '127'); -$manageMembers = array('realnames' => $realnames, 'roles' => $roles, 'hours' => $hours, 'accounts' => $accounts, 'limited' => $limited, 'days' => $days); -$count = array('0','1'); +$manageMembers[0] = array('role' => $roles[0], 'hours' => $hours[0], 'account' => $accounts[0], 'limited' => $limited[0], 'days' => $days[0], 'root' => $executionID, 'type' => 'execution'); +$manageMembers[1] = array('role' => $roles[1], 'hours' => $hours[1], 'account' => $accounts[1], 'limited' => $limited[1], 'days' => $days[1], 'root' => $executionID, 'type' => 'execution'); +$manageMembers[2] = array('role' => $roles[2], 'hours' => $hours[2], 'account' => $accounts[2], 'limited' => $limited[2], 'days' => $days[2], 'root' => $executionID, 'type' => 'execution'); +$count = array(0, 1); $execution = new executionTest(); r($execution->manageMembersTest($executionID, $count[0], $manageMembers)) && p('0:root,type,account') && e('3,execution,user1'); // 团队管理