diff --git a/module/testreport/control.php b/module/testreport/control.php index 8dad9fcf7f..2b8de61ed3 100644 --- a/module/testreport/control.php +++ b/module/testreport/control.php @@ -238,7 +238,6 @@ class testreport extends control } $cases = $this->testreport->getTaskCases($tasks, $begin, $end); $bugInfo = $this->testreport->getBugInfo($tasks, $productIdList, $begin, $end, $builds); - $this->view->begin = $begin; $this->view->end = $end; $this->view->members = $this->dao->select('DISTINCT lastRunner')->from(TABLE_TESTRUN)->where('task')->in(array_keys($tasks))->fetchPairs('lastRunner', 'lastRunner'); @@ -257,6 +256,9 @@ class testreport extends control $this->view->cases = $cases; $this->view->caseSummary = $this->testreport->getResultSummary($tasks, $cases, $begin, $end); + $this->view->datas['testTaskPerRunResult'] = $this->testreport->getPerCaseResult4Report($tasks, $cases, $begin, $end); + $this->view->datas['testTaskPerRunner'] = $this->testreport->getPerCaseRunner4Report($tasks, $cases, $begin, $end); + $this->view->legacyBugs = $bugInfo['legacyBugs']; unset($bugInfo['legacyBugs']); $this->view->bugInfo = $bugInfo; @@ -363,6 +365,9 @@ class testreport extends control $this->view->cases = $cases; $this->view->caseSummary = $this->testreport->getResultSummary($tasks, $cases, $report->begin, $report->end); + + $this->view->datas['testTaskPerRunResult'] = $this->testreport->getPerCaseResult4Report($tasks, $cases, $report->begin, $report->end); + $this->view->datas['testTaskPerRunner'] = $this->testreport->getPerCaseRunner4Report($tasks, $cases, $report->begin, $report->end); $this->view->legacyBugs = $bugInfo['legacyBugs']; unset($bugInfo['legacyBugs']); @@ -442,6 +447,9 @@ class testreport extends control $this->view->storySummary = $this->product->summary($stories); $this->view->caseSummary = $this->testreport->getResultSummary($tasks, $cases, $report->begin, $report->end); + $this->view->datas['testTaskPerRunResult'] = $this->testreport->getPerCaseResult4Report($tasks, $cases, $report->begin, $report->end); + $this->view->datas['testTaskPerRunner'] = $this->testreport->getPerCaseRunner4Report($tasks, $cases, $report->begin, $report->end); + $this->view->legacyBugs = $bugInfo['legacyBugs']; unset($bugInfo['legacyBugs']); $this->view->bugInfo = $bugInfo; diff --git a/module/testreport/model.php b/module/testreport/model.php index b1ee593f23..224d4c3867 100644 --- a/module/testreport/model.php +++ b/module/testreport/model.php @@ -361,6 +361,8 @@ class testreportModel extends model * * @param array $tasks * @param array $cases + * @param string $begin + * @param string $end * @access public * @return string */ @@ -370,6 +372,8 @@ class testreportModel extends model ->leftJoin(TABLE_TESTRUN)->alias('t2')->on('t1.run=t2.id') ->where('t2.task')->in(array_keys($tasks)) ->andWhere('t1.`case`')->in(array_keys($cases)) + ->andWhere('t1.date')->ge($begin) + ->andWhere('t1.date')->le($end . " 23:59:59") ->orderBy('date') ->fetchAll('id'); @@ -383,6 +387,68 @@ class testreportModel extends model return sprintf($this->lang->testreport->caseSummary, count($cases), count($runCasesNum), count($results), count($failResults)); } + /** + * Get per run result for testreport. + * + * @param array $tasks + * @param array $cases + * @param string $begin + * @param string $end + * @access public + * @return string + */ + public function getPerCaseResult4Report($tasks, $cases, $begin, $end) + { + $datas = $this->dao->select("t1.caseResult AS name, COUNT('t1.*') AS value")->from(TABLE_TESTRESULT)->alias('t1') + ->leftJoin(TABLE_TESTRUN)->alias('t2') + ->on('t1.run= t2.id') + ->where('t2.task')->in(array_keys($tasks)) + ->andWhere('t1.`case`')->in(array_keys($cases)) + ->andWhere('t1.date')->ge($begin) + ->andWhere('t1.date')->le($end . " 23:59:59") + ->groupBy('name') + ->orderBy('value DESC') + ->fetchAll('name'); + + if(!$datas) return array(); + + $this->app->loadLang('testcase'); + foreach($datas as $result => $data) $data->name = isset($this->lang->testcase->resultList[$result])? $this->lang->testcase->resultList[$result] : $this->lang->testtask->unexecuted; + + return $datas; + } + + /** + * Get per case runner for testreport. + * + * @param array $tasks + * @param array $cases + * @param string $begin + * @param string $end + * @access public + * @return string + */ + public function getPerCaseRunner4Report($tasks, $cases, $begin, $end) + { + $datas = $this->dao->select("t1.lastRunner AS name, COUNT('t1.*') AS value")->from(TABLE_TESTRESULT)->alias('t1') + ->leftJoin(TABLE_TESTRUN)->alias('t2') + ->on('t1.run= t2.id') + ->where('t2.task')->in(array_keys($tasks)) + ->andWhere('t1.`case`')->in(array_keys($cases)) + ->andWhere('t1.date')->ge($begin) + ->andWhere('t1.date')->le($end . " 23:59:59") + ->groupBy('name') + ->orderBy('value DESC') + ->fetchAll('name'); + + if(!$datas) return array(); + + $users = $this->loadModel('user')->getPairs('noclosed|noletter'); + foreach($datas as $result => $data) $data->name = $result ? zget($users, $result, $result) : $this->lang->testtask->unexecuted; + + return $datas; + } + /** * Get bugs for test *