* Add metric test and modify test code.

This commit is contained in:
songchenxuan
2023-12-19 14:15:04 +08:00
parent 1c437a4ba9
commit 034012e96d
17 changed files with 143 additions and 121 deletions
+25
View File
@@ -349,6 +349,31 @@ class metricTest
return $this->objectModel->getDateTypeByCode($code);
}
/**
* Test isHeaderGroup.
*
* @param array $header
* @access public
* @return bool
*/
public function isHeaderGroup($header)
{
return $this->objectModel->isHeaderGroup($header);
}
/**
* Test isSystemMetric.
*
* @param array $record
* @access public
* @return bool
*/
public function isSystemMetric($record)
{
$result = array((object)$record);
return $this->objectModel->isSystemMetric($result);
}
/**
* Test getMetricCycle.
*
+5 -8
View File
@@ -1,18 +1,15 @@
#!/usr/bin/env php
<?php
/**
title=getByCode
cid=1
pid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
$metric = new metricTest();
/**
title=getByCode
cid=1
pid=1
*/
r($metric->getByCode('count_of_annual_closed_top_program')) && p('name') && e('按系统统计的年度关闭一级项目集数'); // 获取code为count_of_annual_closed_top_program的度量名称
r($metric->getByCode('day_of_annual_effort')) && p('name') && e('按系统统计的年度投入总人天'); // 获取code为day_of_annual_effort的度量名称
r($metric->getByCode('day_of_annual_effort', 'id')) && p('name') && e('~~'); // 获取code为day_of_annual_effort的度量名称,传入了查询的字段,因此查询不到
+5 -8
View File
@@ -1,18 +1,15 @@
#!/usr/bin/env php
<?php
/**
title=getByID
cid=1
pid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
$metric = new metricTest();
/**
title=getByID
cid=1
pid=1
*/
r($metric->getByID(1)) && p('name') && e('按系统统计的所有层级的项目集总数'); // 获取id为1的度量名称
r($metric->getByID(10)) && p('code') && e('count_of_annual_closed_top_program'); // 获取id为10的度量代号
r($metric->getByID(100, 'id')) && p('name') && e('~~'); // 获取id为100并指定fieldList后检测名称不应该存在
+8 -11
View File
@@ -1,19 +1,16 @@
#!/usr/bin/env php
<?php
/**
title=getDataStatement
timeout=0
cid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
su('admin');
$metric = new metricTest();
/**
title=getDataStatement
timeout=0
cid=1
*/
$metricList = array();
$metricList[0] = 'count_of_bug';
$metricList[1] = 'count_of_annual_created_product';
@@ -32,7 +29,7 @@ $expectSQL[5] = "select t1.product,t1.status,t1.closeddate from `zt_bug` as t1
r($metric->getDataStatement($metricList[0], 'system', 'scale')) && p('') && e("select t1.id from `zt_bug` as t1 left join `zt_product` as t2 on t1.product=t2.id where t1.deleted = '0' and t2.deleted = '0' and t2.shadow = '0'"); // 测试count_of_bug
r($metric->getDataStatement($metricList[1], 'system', 'scale')) && p('') && e("select t1.createddate from `zt_product` as t1 where t1.deleted = '0' and t1.shadow = '0' and not find_in_set('or', t1.vision) and not find_in_set('lite', t1.vision)"); // 测试count_of_annual_created_product
r($metric->getDataStatement($metricList[2], 'system', 'scale')) && p('') && e("select t1.createddate from `zt_release` as t1 left join `zt_project` as t2 on concat(',', t2.id, ',') like concat('%', t1.project, '%') left join `zt_product` as t3 on t1.product=t3.id where t1.deleted = '0' and t3.deleted = '0' and not find_in_set('or', t2.vision) and not find_in_set('lite', t2.vision)"); // 测试count_of_weekly_created_release
r($metric->getDataStatement($metricList[3], 'product', 'scale')) && p('') && e("select t1.product from `zt_case` as t1 left join `zt_product` as t2 on t1.product=t2.id where t1.deleted = '0' and t2.deleted = '0' and t2.shadow = '0' and not find_in_set('or', t2.vision) and not find_in_set('lite', t2.vision)"); // 测试count_of_case_in_product
r($metric->getDataStatement($metricList[4], 'product', 'scale')) && p('') && e("select t1.product,t1.resolution,t1.closeddate from `zt_bug` as t1 left join `zt_product` as t2 on t1.product=t2.id where t1.deleted = '0' and t2.deleted = '0' and t2.shadow = '0'"); // 测试count_of_annual_fixed_bug_in_product
r($metric->getDataStatement($metricList[2], 'system', 'scale')) && p('') && e("select t1.createddate from `zt_release` as t1 left join `zt_project` as t2 on concat(',', t2.id, ',') like concat('%', t1.project, '%') left join `zt_product` as t3 on t1.product=t3.id where t1.deleted = '0' and t3.deleted = '0' and not find_in_set('or', t2.vision) and not find_in_set('lite', t2.vision)"); // 测试count_of_weekly_created_release
r($metric->getDataStatement($metricList[3], 'product', 'scale')) && p('') && e("select t1.product from `zt_case` as t1 left join `zt_product` as t2 on t1.product=t2.id where t1.deleted = '0' and t2.deleted = '0' and t2.shadow = '0' and not find_in_set('or', t2.vision) and not find_in_set('lite', t2.vision)"); // 测试count_of_case_in_product
r($metric->getDataStatement($metricList[4], 'product', 'scale')) && p('') && e("select t1.product,t1.resolution,t1.closeddate from `zt_bug` as t1 left join `zt_product` as t2 on t1.product=t2.id where t1.deleted = '0' and t2.deleted = '0' and t2.shadow = '0'"); // 测试count_of_annual_fixed_bug_in_product
r($metric->getDataStatement($metricList[5], 'product', 'scale')) && p('') && e("select t1.product,t1.status,t1.closeddate from `zt_bug` as t1 left join `zt_product` as t2 on t1.product=t2.id where t1.deleted = '0' and t2.deleted = '0' and t2.shadow = '0'"); // 测试count_of_daily_closed_bug_in_product
+5 -8
View File
@@ -1,19 +1,16 @@
#!/usr/bin/env php
<?php
/**
title=getDateLabels
timeout=0
cid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
su('admin');
$metric = new metricTest();
/**
title=getDateLabels
timeout=0
cid=1
*/
r($metric->getDateLabels('year')) && p('3;5;10;all') && e('近3年,近5年,近10年,全部'); // 测试传入year的情况
r($metric->getDateLabels('month')) && p('6;12;24;36') && e('近6个月,近12个月,近24个月,近36个月'); // 测试传入month的情况
r($metric->getDateLabels('week')) && p('4;8;12;16') && e('近4周,近8周,近12周,近16周'); // 测试传入week的情况
+9 -12
View File
@@ -1,19 +1,16 @@
#!/usr/bin/env php
<?php
/**
title=getDateType
timeout=0
cid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
su('admin');
$metric = new metricTest();
/**
title=getDateType
timeout=0
cid=1
*/
$day = array('day');
$month = array('month');
$week = array('week');
@@ -31,10 +28,10 @@ $dateList[7] = array('day', 'month', 'week', 'year');
$dateList[8] = array('product');
r($metric->getDateType($day)) && p('') && e('day'); // 测试传入day
r($metric->getDateType($month)) && p('') && e('month'); // 测试传入month
r($metric->getDateType($week)) && p('') && e('week'); // 测试传入week
r($metric->getDateType($year)) && p('') && e('year'); // 测试传入year
r($metric->getDateType($dateList[0])) && p('') && e('day'); // 测试传入day,month
r($metric->getDateType($month)) && p('') && e('month'); // 测试传入month
r($metric->getDateType($week)) && p('') && e('week'); // 测试传入week
r($metric->getDateType($year)) && p('') && e('year'); // 测试传入year
r($metric->getDateType($dateList[0])) && p('') && e('day'); // 测试传入day,month
r($metric->getDateType($dateList[1])) && p('') && e('week'); // 测试传入month,week
r($metric->getDateType($dateList[2])) && p('') && e('week'); // 测试传入week,year
r($metric->getDateType($dateList[3])) && p('') && e('day'); // 测试传入day,year
+6 -10
View File
@@ -1,20 +1,16 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
su('admin');
$metric = new metricTest();
zdTable('metriclib')->config('metriclib_system_product', true)->gen(80);
/**
title=getDateTypeByCode
timeout=0
cid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
su('admin');
zdTable('metriclib')->config('metriclib_system_product', true)->gen(80);
$metric = new metricTest();
$codeList = array();
$codeList[0] = 'count_of_bug';
+5 -8
View File
@@ -1,18 +1,15 @@
#!/usr/bin/env php
<?php
/**
title=getList
timeout=0
cid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
$metric = new metricTest();
/**
title=getList
timeout=0
cid=1
*/
r($metric->getList('system', 'all')) && p('0:code') && e('count_of_annual_created_doc'); // 获取系统范围内的所有度量项
r($metric->getList('system', 'wait')) && p('') && e('0'); // 获取系统范围内未发布的度量项
r($metric->getList('system', 'released')) && p('1:code') && e('count_of_doc'); // 获取系统范围内发布的度量项
@@ -1,17 +1,14 @@
#!/usr/bin/env php
<?php
/**
title=getListByCollect
cid=1
pid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
$metric = new metricTest();
su('admin');
/**
title=getListByCollect
cid=1
pid=1
*/
r($metric->getListByCollect()) && p('0:id,code') && e('10,count_of_annual_closed_top_program');
+5 -7
View File
@@ -1,17 +1,15 @@
#!/usr/bin/env php
<?php
/**
title=getListByFilter
cid=1
pid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
$metric = new metricTest();
/**
title=getListByFilter
cid=1
pid=1
*/
$filters1 = array('scope' => array('system', 'execution'), 'object' => array('program', 'execution'), 'purpose' => array('scale', 'cost'));
$filters2 = array('scope' => array('execution'));
$filters3 = array('object' => array('execution'));
@@ -5,8 +5,6 @@ include dirname(__FILE__, 2) . '/calc.class.php';
$metric = new metricTest();
zdTable('metriclib')->config('metriclib_system_product', true)->gen(80);
/**
title=getMetricCycle
@@ -1,19 +1,16 @@
#!/usr/bin/env php
<?php
/**
title=getMetricRecordDateField
timeout=0
cid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
su('admin');
$metric = new metricTest();
/**
title=getMetricRecordDateField
timeout=0
cid=1
*/
$metricList = array();
$metricList[0] = 'count_of_bug';
$metricList[1] = 'count_of_annual_created_product';
@@ -1,18 +1,15 @@
#!/usr/bin/env php
<?php
/**
title=getMetricsByIDList
cid=1
pid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
$metric = new metricTest();
/**
title=getMetricsByIDList
cid=1
pid=1
*/
r($metric->getMetricsByIDList('1,2')) && p('0:code;1:code') && e('count_of_program,count_of_doing_program'); // 使用字符串传入获取metric
r($metric->getMetricsByIDList(array(1,2))) && p('0:code;1:code') && e('count_of_program,count_of_doing_program'); // 使用数组传入获取metric
r($metric->getMetricsByIDList('')) && p() && e('0'); // 传入一个空字符串没有metric返回
@@ -1,17 +1,14 @@
#!/usr/bin/env php
<?php
/**
title=getOldMetricList
cid=1
pid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
$metric = new metricTest();
/**
title=getOldMetricList
cid=1
pid=1
*/
r($metric->getOldMetricList()) && p('10:scope,object,code') && e('project,stage,pgmDevelPlanDays');
r($metric->getOldMetricList()) && p('40:scope,object,code') && e('project,finance,pgmRequestRealHours');
+5 -8
View File
@@ -1,18 +1,15 @@
#!/usr/bin/env php
<?php
/**
title=getScopePairs
cid=1
pid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
$metric = new metricTest();
/**
title=getScopePairs
cid=1
pid=1
*/
r($metric->getScopePairs()) && p('0:value') && e('system'); // 获取全部的scopePair,取第一个
r($metric->getScopePairs()) && p('1:value') && e('program'); // 获取全部的scopePair,取第二个
r($metric->getScopePairs(false)) && p('0:value') && e('system'); // 获取部分的scopePair,取第一个
@@ -1,18 +1,14 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
$metric = new metricTest();
/**
title=groupMetricByObject
cid=1
pid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
$metric = new metricTest();
$systemMetrics = $metric->getList('system', 'all');
r($metric->groupMetricByObject($systemMetrics, true, array('group' => 'doc', 'key' => 0))) && p('code') && e('count_of_annual_created_doc'); // 获取系统度量项文档分组的第3个度量的code
@@ -0,0 +1,42 @@
#!/usr/bin/env php
<?php
/**
title=isSystemMetric
cid=1
pid=1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/calc.class.php';
$metric = new metricTest();
$records = array();
$records[1] = array('system' => 1);
$records[2] = array('program' => 1);
$records[3] = array('project' => 1);
$records[4] = array('product' => 1);
$records[5] = array('execution' => 1);
$records[6] = array('code' => 1);
$records[7] = array('pipeline' => 1);
$records[8] = array('user' => 'admin');
$records[9] = array('dept' => 1);
$records[10] = array('year' => 2023);
$records[11] = array('month' => 12);
$records[12] = array('week' => 52);
$records[13] = array('day' => 21);
$records[14] = array('value' => 1);
r($metric->isSystemMetric($records[1])) && p() && e('1');
r($metric->isSystemMetric($records[2])) && p() && e('0');
r($metric->isSystemMetric($records[3])) && p() && e('0');
r($metric->isSystemMetric($records[4])) && p() && e('0');
r($metric->isSystemMetric($records[5])) && p() && e('0');
r($metric->isSystemMetric($records[6])) && p() && e('1');
r($metric->isSystemMetric($records[7])) && p() && e('1');
r($metric->isSystemMetric($records[8])) && p() && e('0');
r($metric->isSystemMetric($records[9])) && p() && e('0');
r($metric->isSystemMetric($records[10])) && p() && e('1');
r($metric->isSystemMetric($records[11])) && p() && e('1');
r($metric->isSystemMetric($records[12])) && p() && e('1');
r($metric->isSystemMetric($records[13])) && p() && e('1');
r($metric->isSystemMetric($records[14])) && p() && e('1');