* measurement: add unit test for metrics.

This commit is contained in:
zhouxin
2023-07-20 17:11:01 +08:00
parent 018545e0a9
commit c6763b8fd3
2 changed files with 49 additions and 0 deletions
@@ -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'); // 测试不存在年份的新增项目数。