diff --git a/module/execution/model.php b/module/execution/model.php index 2c6192dce3..cc3df08a4c 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4210,30 +4210,27 @@ class executionModel extends model } /** + * 构造Bug的搜索表单。 * Build bug search form. * - * @param array $products - * @param int $queryID - * @param string $actionURL + * @param array $products + * @param int $queryID + * @param string $actionURL + * @param string $type * @access public * @return void */ - public function buildBugSearchForm($products, $queryID, $actionURL, $type = 'execution') + public function buildBugSearchForm(array $products, int $queryID, string $actionURL, string $type = 'execution') { $modules = array(); $builds = array('' => '', 'trunk' => $this->lang->trunk); foreach($products as $product) { $productModules = $this->loadModel('tree')->getOptionMenu($product->id, 'bug'); + foreach($productModules as $moduleID => $moduleName) $modules[$moduleID] = ((count($products) >= 2 and $moduleID) ? $product->name : '') . $moduleName; + $productBuilds = $this->loadModel('build')->getBuildPairs($product->id, 'all', 'noempty|notrunk|withbranch'); - foreach($productModules as $moduleID => $moduleName) - { - $modules[$moduleID] = ((count($products) >= 2 and $moduleID) ? $product->name : '') . $moduleName; - } - foreach($productBuilds as $buildID => $buildName) - { - $builds[$buildID] = ((count($products) >= 2 and $buildID) ? $product->name . '/' : '') . $buildName; - } + foreach($productBuilds as $buildID => $buildName) $builds[$buildID] = ((count($products) >= 2 and $buildID) ? $product->name . '/' : '') . $buildName; } $branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products)); @@ -4268,6 +4265,7 @@ class executionModel extends model $this->config->bug->search['module'] = $type == 'execution' ? 'executionBug' : 'projectBug'; $this->config->bug->search['actionURL'] = $actionURL; $this->config->bug->search['queryID'] = $queryID; + $this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts($products); $this->config->bug->search['params']['module']['values'] = $modules; $this->config->bug->search['params']['openedBuild']['values'] = $builds; diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index 5c5c93788c..4a5910fe20 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -2828,20 +2828,22 @@ class executionTest } /** - * Test build bug search form. + * 构造Bug的搜索表单。 + * Build bug search form. * * @param int $productID * @param int $queryID + * @param string $type * @access public * @return int */ - public function buildBugSearchFormTest($productID, $queryID) + public function buildBugSearchFormTest(int $productID, int $queryID, string $type = 'execution'): int { $product = $this->productModel->getByID($productID); - if(empty($product)) return '0'; + if(empty($product)) return 0; $this->executionModel->loadModel('bug'); - $this->executionModel->buildBugSearchForm(array($productID => $product), $queryID, 'searchBug'); + $this->executionModel->buildBugSearchForm(array($productID => $product), $queryID, 'searchBug', $type); return $_SESSION['executionBugsearchParams']['queryID']; } diff --git a/module/execution/test/model/buildbugsearchform.php b/module/execution/test/model/buildbugsearchform.php index bd7fbabfcf..07a184bde7 100644 --- a/module/execution/test/model/buildbugsearchform.php +++ b/module/execution/test/model/buildbugsearchform.php @@ -58,21 +58,21 @@ su('admin'); /** title=测试executionModel->buildBugSearchForm(); +timeout=0 cid=1 -pid=1 - -正确的产品,正确的queryID >> 1 -错误的产品,正确的queryID >> 0 -正确的产品,错误的queryID >> 0 -错误的产品,错误的queryID >> 0 */ -$productIDList = array('1', '0'); -$queryIDList = array('0', '1'); +$productIDList = array(1, 0); +$queryIDList = array(0, 1); +$typeList = array('execution', 'project'); $execution = new executionTest(); -r($execution->buildBugSearchFormTest($productIDList[0], $queryIDList[1])) && p() && e('1'); // 正确的产品,正确的queryID -r($execution->buildBugSearchFormTest($productIDList[1], $queryIDList[1])) && p() && e('0'); // 错误的产品,正确的queryID -r($execution->buildBugSearchFormTest($productIDList[0], $queryIDList[0])) && p() && e('0'); // 正确的产品,错误的queryID -r($execution->buildBugSearchFormTest($productIDList[1], $queryIDList[0])) && p() && e('0'); // 错误的产品,错误的queryID +r($execution->buildBugSearchFormTest($productIDList[0], $queryIDList[1], $typeList[0])) && p() && e('1'); // 测试获取execution下的正确的产品,正确的queryID +r($execution->buildBugSearchFormTest($productIDList[1], $queryIDList[1], $typeList[0])) && p() && e('0'); // 测试获取execution下的错误的产品,正确的queryID +r($execution->buildBugSearchFormTest($productIDList[0], $queryIDList[0], $typeList[0])) && p() && e('0'); // 测试获取execution下的正确的产品,错误的queryID +r($execution->buildBugSearchFormTest($productIDList[1], $queryIDList[0], $typeList[0])) && p() && e('0'); // 测试获取execution下的错误的产品,错误的queryID +r($execution->buildBugSearchFormTest($productIDList[0], $queryIDList[1], $typeList[1])) && p() && e('0'); // 测试获取project下的正确的产品,正确的queryID +r($execution->buildBugSearchFormTest($productIDList[1], $queryIDList[1], $typeList[1])) && p() && e('0'); // 测试获取project下的错误的产品,正确的queryID +r($execution->buildBugSearchFormTest($productIDList[0], $queryIDList[0], $typeList[1])) && p() && e('0'); // 测试获取project下的正确的产品,错误的queryID +r($execution->buildBugSearchFormTest($productIDList[1], $queryIDList[0], $typeList[1])) && p() && e('0'); // 测试获取project下的错误的产品,错误的queryID