* Add unit test for metricModel-getDateLabels.

This commit is contained in:
zhouxin
2023-12-18 14:44:58 +08:00
parent ce4a20f981
commit 3ec15e336f
2 changed files with 32 additions and 0 deletions
+12
View File
@@ -160,4 +160,16 @@ class metricTest
return $dataset->$dataSource($fieldList);
}
/**
* Test getDateLabels()
*
* @param string $dateType
* @access public
* @return array
*/
public function getDateLabels($dateType)
{
return $this->objectModel->getDateLabels($dateType);
}
}
+20
View File
@@ -0,0 +1,20 @@
#!/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();
/**
title=getDateLabels
cid=1
pid=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的情况
r($metric->getDateLabels('day')) && p('7;14;21;28') && e('近7天,近14天,近21天,近28天'); // 测试传入day的情况