* Add unit test for metric.
This commit is contained in:
+3
-4
@@ -28,12 +28,12 @@ class count_of_undelayed_finished_execution_which_annual_finished extends baseCa
|
||||
|
||||
public function calculate($row)
|
||||
{
|
||||
if(empty($row->closedDate) or empty($row->firstEnd)) return false;
|
||||
if(empty($row->closedDate) || empty($row->firstEnd)) return false;
|
||||
|
||||
$year = substr($row->closedDate, 0, 4);
|
||||
if($year == '0000') return false;
|
||||
|
||||
if($row->status == 'closed' and $row->closedDate <= $row->firstEnd)
|
||||
if($row->status == 'closed' && $row->closedDate <= $row->firstEnd)
|
||||
{
|
||||
if(!isset($this->result[$year])) $this->result[$year] = 0;
|
||||
$this->result[$year] ++;
|
||||
@@ -42,8 +42,7 @@ class count_of_undelayed_finished_execution_which_annual_finished extends baseCa
|
||||
|
||||
public function getResult($options = array())
|
||||
{
|
||||
$records = array();
|
||||
foreach($this->result as $year => $value) $records[] = array('year' => $year, 'value' => $value);
|
||||
$records = $this->getRecords(array('year', 'value'));
|
||||
return $this->filterByOptions($records, $options);
|
||||
}
|
||||
}
|
||||
|
||||
module/metric/test/calc/global/scale/count_of_undelayed_finished_execution_which_annual_finished.php
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 7) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 4) . '/calc.class.php';
|
||||
|
||||
zdTable('project')->config('project_close', $useCommon = true, $levels = 4)->gen(10);
|
||||
zdTable('project')->config('execution_undelayed', $useCommon = true, $levels = 4)->gen(100, false);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
/**
|
||||
|
||||
title=count_of_undelayed_finished_execution_which_annual_finished
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
*/
|
||||
|
||||
r(count($calc->getResult())) && p('') && e('2'); // 测试分组数
|
||||
r($calc->getResult(array('year' => '2011'))) && p('0:value') && e('8'); // 测试2011年完成执行中按期完成执行数
|
||||
r($calc->getResult(array('year' => '2012'))) && p('0:value') && e('8'); // 测试2012年完成执行中按期完成执行数
|
||||
Reference in New Issue
Block a user