* measurement: add unit test for metrics.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 7) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 4) . '/calc.class.php';
|
||||
|
||||
zdTable('project')->config('project_status', $useCommon = true, $levels = 4)->gen(400);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
/**
|
||||
|
||||
title=count_of_monthly_closed_project
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
*/
|
||||
|
||||
r(count($calc->getResult())) && p('') && e('24'); // 测试分组数。
|
||||
|
||||
r($calc->getResult(array('year' => '2011', 'month' => '05'))) && p('0:value') && e('1'); // 测试2010-01关闭的项目数。
|
||||
r($calc->getResult(array('year' => '2018', 'month' => '07'))) && p('0:value') && e('2'); // 测试2018-03关闭的项目数。
|
||||
r($calc->getResult(array('year' => '9999', 'month' => '01'))) && p('') && e('0'); // 测试不存在年份的关闭项目数。
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 7) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 4) . '/calc.class.php';
|
||||
|
||||
zdTable('project')->config('project_status', $useCommon = true, $levels = 4)->gen(400);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
/**
|
||||
|
||||
title=count_of_monthly_created_project
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
*/
|
||||
|
||||
r(count($calc->getResult())) && p('') && e('67'); // 测试分组数。
|
||||
|
||||
r($calc->getResult(array('year' => '2010', 'month' => '01'))) && p('0:value') && e('4'); // 测试2010-01新增的项目数。
|
||||
r($calc->getResult(array('year' => '2018', 'month' => '03'))) && p('0:value') && e('1'); // 测试2018-03新增的项目数。
|
||||
r($calc->getResult(array('year' => '9999', 'month' => '01'))) && p('') && e('0'); // 测试不存在年份的新增项目数。
|
||||
|
||||
Reference in New Issue
Block a user