* Add unit test for metric.

This commit is contained in:
zhouxin
2023-08-02 10:59:13 +08:00
parent df7fec8e2d
commit d7c1089c2f
9 changed files with 54 additions and 11 deletions
@@ -35,7 +35,7 @@ class count_of_doing_program extends baseCalc
public function getResult($options = array())
{
$records = array(array('value' => $this->result));
$records = $this->getRecords(array('value'));
return $this->filterByOptions($records, $options);
}
}
@@ -3,7 +3,7 @@
include dirname(__FILE__, 7) . '/test/lib/init.php';
include dirname(__FILE__, 4) . '/calc.class.php';
zdTable('project')->config('program', $useCommon = true, $levels = 4)->gen(356, true, false);
zdTable('project')->config('program_closed', $useCommon = true, $levels = 4)->gen(356, true, false);
$metric = new metricTest();
$calc = $metric->calcMetric(__FILE__);
@@ -3,7 +3,7 @@
include dirname(__FILE__, 7) . '/test/lib/init.php';
include dirname(__FILE__, 4) . '/calc.class.php';
zdTable('project')->config('program', $useCommon = true, $levels = 4)->gen(356, true, false);
zdTable('project')->config('program_closed', $useCommon = true, $levels = 4)->gen(356, true, false);
$metric = new metricTest();
$calc = $metric->calcMetric(__FILE__);
@@ -13,14 +13,14 @@ cid=1
*/
zdTable('project')->config('program', $useCommon = true, $levels = 4)->gen(356, true, false);
zdTable('project')->config('program_closed', $useCommon = true, $levels = 4)->gen(356, true, false);
$calc = $metric->calcMetric(__FILE__);
r($calc->getResult()) && p('0:value') && e('180'); // 测试356条项目集数。
zdTable('project')->config('program', $useCommon = true, $levels = 4)->gen(652, true, false);
zdTable('project')->config('program_closed', $useCommon = true, $levels = 4)->gen(652, true, false);
$calc = $metric->calcMetric(__FILE__);
r($calc->getResult()) && p('0:value') && e('328'); // 测试652条项目集数。
zdTable('project')->config('program', $useCommon = true, $levels = 4)->gen(1265, true, false);
zdTable('project')->config('program_closed', $useCommon = true, $levels = 4)->gen(1265, true, false);
$calc = $metric->calcMetric(__FILE__);
r($calc->getResult()) && p('0:value') && e('633'); // 测试1265条项目集数。
@@ -3,7 +3,7 @@
include dirname(__FILE__, 7) . '/test/lib/init.php';
include dirname(__FILE__, 4) . '/calc.class.php';
zdTable('project')->config('program', $useCommon = true, $levels = 4)->gen(356, true, false);
zdTable('project')->config('program_closed', $useCommon = true, $levels = 4)->gen(356, true, false);
$metric = new metricTest();
$calc = $metric->calcMetric(__FILE__);
@@ -0,0 +1,19 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 7) . '/test/lib/init.php';
include dirname(__FILE__, 4) . '/calc.class.php';
zdTable('project')->config('program', $useCommon = true, $levels = 4)->gen(356, true, false);
$metric = new metricTest();
$calc = $metric->calcMetric(__FILE__);
/**
title=count_of_doing_program
timeout=0
cid=1
*/
r($calc->getResult()) && p('0:value') && e('45'); // 测试进行中的项目集数量
@@ -13,14 +13,14 @@ cid=1
*/
zdTable('project')->config('program', $useCommon = true, $levels = 4)->gen(356, true, false);
zdTable('project')->config('program_closed', $useCommon = true, $levels = 4)->gen(356, true, false);
$calc = $metric->calcMetric(__FILE__);
r($calc->getResult()) && p('0:value') && e('45'); // 测试356条项目集数。
zdTable('project')->config('program', $useCommon = true, $levels = 4)->gen(652, true, false);
zdTable('project')->config('program_closed', $useCommon = true, $levels = 4)->gen(652, true, false);
$calc = $metric->calcMetric(__FILE__);
r($calc->getResult()) && p('0:value') && e('82'); // 测试652条项目集数。
zdTable('project')->config('program', $useCommon = true, $levels = 4)->gen(1265, true, false);
zdTable('project')->config('program_closed', $useCommon = true, $levels = 4)->gen(1265, true, false);
$calc = $metric->calcMetric(__FILE__);
r($calc->getResult()) && p('0:value') && e('159'); // 测试1265条项目集数。
+1 -1
View File
@@ -10,7 +10,7 @@ fields:
- field: grade
range: 1{1},2{1},3{1},4{1}
- field: status
range: closed
range: wait{1},doing{1},suspended{1},closed{1}
- field: openedDate
range: "20100101 000000-20210101 230000:10D"
type: timestamp
@@ -0,0 +1,24 @@
---
title: zt_project
author: qixinzhi
version: "1.0"
fields:
- field: id
range: 1-10000
- field: type
range: program
- field: grade
range: 1{1},2{1},3{1},4{1}
- field: status
range: closed
- field: openedDate
range: "20100101 000000-20210101 230000:10D"
type: timestamp
format: YYYY-MM-DD hh:mm:ss
- field: closedDate
range: "20110101 000000-20210101 230000:10D"
type: timestamp
format: YYYY-MM-DD hh:mm:ss
- field: deleted
range: 0{4},1{4}
---