* Optimize code for testreport::getResultSummary.
This commit is contained in:
@@ -204,12 +204,12 @@ class testreportModel extends model
|
||||
->orderBy('date')
|
||||
->fetchAll('id');
|
||||
|
||||
$failResults = 0;
|
||||
$runCasesNum = array();
|
||||
foreach($results as $result) $runCasesNum[$result->run] = $result->caseResult;
|
||||
foreach($runCasesNum as $lastResult) if($lastResult == 'fail') $failResults++;
|
||||
$failResults = 0;
|
||||
$runCasesResults = array();
|
||||
foreach($results as $result) $runCasesResults[$result->run] = $result->caseResult;
|
||||
foreach($runCasesResults as $lastResult) if($lastResult == 'fail') $failResults++;
|
||||
|
||||
return sprintf($this->lang->testreport->caseSummary, $caseCount, count($runCasesNum), count($results), $failResults);
|
||||
return sprintf($this->lang->testreport->caseSummary, $caseCount, count($runCasesResults), count($results), $failResults);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/testreport.class.php';
|
||||
su('admin');
|
||||
|
||||
zdTable('case')->gen(10);
|
||||
zdTable('testtask')->gen(10);
|
||||
@@ -10,6 +9,8 @@ zdTable('testrun')->gen(10);
|
||||
zdTable('testresult')->gen(10);
|
||||
zdTable('testreport')->gen(10);
|
||||
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 testreportModel->getResultSummary();
|
||||
@@ -25,4 +26,4 @@ $reportID = '1';
|
||||
|
||||
$testreport = new testreportTest();
|
||||
r($testreport->getResultSummaryTest($taskID[0], $reportID)) && p() && e('共有<strong>4</strong>个用例,共执行<strong>4</strong>个用例,产生了<strong>4</strong>个结果,失败的用例有<strong>2</strong>个。'); //正常查询
|
||||
r($testreport->getResultSummaryTest($taskID[1], $reportID)) && p() && e('共有<strong>0</strong>个用例,共执行<strong>0</strong>个用例,产生了<strong>0</strong>个结果,失败的用例有<strong>0</strong>个。'); //taskID为空查询
|
||||
r($testreport->getResultSummaryTest($taskID[1], $reportID)) && p() && e('共有<strong>0</strong>个用例,共执行<strong>0</strong>个用例,产生了<strong>0</strong>个结果,失败的用例有<strong>0</strong>个。'); //taskID为空查询
|
||||
|
||||
Reference in New Issue
Block a user