Merge branch release/21.7.8 of zentao/zentaopms (#12661)

This commit is contained in:
刘刚
2025-12-05 09:16:28 +08:00
committed by Gitfox
20 changed files with 10 additions and 2103 deletions
File diff suppressed because it is too large Load Diff
@@ -1,45 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::addFormatter4Echart();
timeout=0
cid=15562
- 执行$result1 @1
- 执行$result2 @1
- 执行$result3 @1
- 执行$result4 @1
- 执行$result5 @1
- 执行$result6 @1
- 执行$result7 @1
*/
// 1. 导入依赖
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
// 2. 用户登录
su('admin');
// 3. 创建测试实例
$chartTest = new chartTest();
// 4. 执行测试步骤(至少5个)
$result1 = $chartTest->addFormatter4EchartTest(array('series' => array(array('type' => 'liquidFill', 'data' => array(0.75), 'label' => array())), 'tooltip' => array('show' => true)), 'waterpolo');
$result2 = $chartTest->addFormatter4EchartTest(array('series' => array(), 'xAxis' => array('type' => 'category', 'data' => array()), 'yAxis' => array('type' => 'value')), 'line');
$result3 = $chartTest->addFormatter4EchartTest(array('series' => array(), 'xAxis' => array('type' => 'category'), 'yAxis' => array('type' => 'value')), 'cluBarX');
$result4 = $chartTest->addFormatter4EchartTest(array('series' => array(array('type' => 'pie', 'data' => array())), 'legend' => array()), 'pie');
$result5 = $chartTest->addFormatter4EchartTest(array('series' => array(), 'xAxis' => array('type' => 'bar'), 'yAxis' => array()), 'stackedBar');
$result6 = $chartTest->addFormatter4EchartTest(array('series' => array(), 'xAxis' => array(), 'yAxis' => array('type' => 'category')), 'cluBarY');
$result7 = $chartTest->addFormatter4EchartTest(array(), 'line');
r(is_array($result1)) && p() && e('1');
r(is_array($result2)) && p() && e('1');
r(is_array($result3)) && p() && e('1');
r(is_array($result4)) && p() && e('1');
r(is_array($result5)) && p() && e('1');
r(is_array($result6)) && p() && e('1');
r(is_array($result7)) && p() && e('1');
@@ -1,45 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::addRotate4Echart();
timeout=0
cid=15563
- 执行$result1 @1
- 执行$result2['xAxis']['axisLabel']['rotate']) ? $result2['xAxis']['axisLabel']['rotate'] : 0 @30
- 执行$result3['yAxis']['axisLabel']['rotate']) ? $result3['yAxis']['axisLabel']['rotate'] : 0 @30
- 执行$result4['xAxis']['axisLabel']['rotate']) ? $result4['xAxis']['axisLabel']['rotate'] : 0 @30
- 执行$result5['yAxis']['axisLabel']['rotate']) ? $result5['yAxis']['axisLabel']['rotate'] : 0 @30
- 执行$result6 @1
- 执行$result7 @1
*/
// 1. 导入依赖
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
// 2. 用户登录
su('admin');
// 3. 创建测试实例
$chartTest = new chartTest();
// 4. 执行测试步骤(至少5个)
$result1 = $chartTest->addRotate4EchartTest(array('series' => array(array('type' => 'pie', 'data' => array())), 'xAxis' => array(), 'yAxis' => array()), array('type' => 'pie', 'rotateX' => 'use', 'rotateY' => 'use'), 'pie');
$result2 = $chartTest->addRotate4EchartTest(array('series' => array(), 'xAxis' => array('type' => 'category'), 'yAxis' => array('type' => 'value')), array('type' => 'line', 'rotateX' => 'use'), 'line');
$result3 = $chartTest->addRotate4EchartTest(array('series' => array(), 'xAxis' => array('type' => 'category'), 'yAxis' => array('type' => 'value')), array('type' => 'cluBarX', 'rotateY' => 'use'), 'cluBarX');
$result4 = $chartTest->addRotate4EchartTest(array('series' => array(), 'xAxis' => array('type' => 'category'), 'yAxis' => array('type' => 'value')), array('type' => 'stackedBar', 'rotateX' => 'use', 'rotateY' => 'use'), 'stackedBar');
$result5 = $result4;
$result6 = $chartTest->addRotate4EchartTest(array('series' => array(), 'xAxis' => array('type' => 'value'), 'yAxis' => array('type' => 'category')), array('type' => 'cluBarY', 'rotateX' => 'no'), 'cluBarY');
$result7 = $chartTest->addRotate4EchartTest(array('series' => array(), 'xAxis' => array('type' => 'value'), 'yAxis' => array('type' => 'category')), array('type' => 'stackedBarY'), 'stackedBarY');
r(is_array($result1)) && p() && e('1');
r(isset($result2['xAxis']['axisLabel']['rotate']) ? $result2['xAxis']['axisLabel']['rotate'] : 0) && p() && e('30');
r(isset($result3['yAxis']['axisLabel']['rotate']) ? $result3['yAxis']['axisLabel']['rotate'] : 0) && p() && e('30');
r(isset($result4['xAxis']['axisLabel']['rotate']) ? $result4['xAxis']['axisLabel']['rotate'] : 0) && p() && e('30');
r(isset($result5['yAxis']['axisLabel']['rotate']) ? $result5['yAxis']['axisLabel']['rotate'] : 0) && p() && e('30');
r(is_array($result6)) && p() && e('1');
r(is_array($result7)) && p() && e('1');
-32
View File
@@ -1,32 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::checkAccess();
timeout=0
cid=15564
- 步骤1:管理员admin访问有权限的图表ID=1 @success
- 步骤2:管理员admin访问有权限的图表ID=5,method='view' @success
- 步骤3:普通用户user1访问有权限的图表ID=3 @success
- 步骤4:普通用户user1访问无权限的图表ID=6 @access_denied
- 步骤5:访客用户test1访问无权限的图表ID=10 @access_denied
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
zenData('user')->gen(10);
su('admin');
$chartTest = new chartTest();
r($chartTest->checkAccessTest(1, 'preview')) && p() && e('success'); // 步骤1:管理员admin访问有权限的图表ID=1
r($chartTest->checkAccessTest(5, 'view')) && p() && e('success'); // 步骤2:管理员admin访问有权限的图表ID=5,method='view'
su('user1');
r($chartTest->checkAccessTest(3, 'preview')) && p() && e('success'); // 步骤3:普通用户user1访问有权限的图表ID=3
r($chartTest->checkAccessTest(6, 'preview')) && p() && e('access_denied'); // 步骤4:普通用户user1访问无权限的图表ID=6
su('test1');
r($chartTest->checkAccessTest(10, 'preview')) && p() && e('access_denied'); // 步骤5:访客用户test1访问无权限的图表ID=10
-39
View File
@@ -1,39 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::genCluBar();
timeout=0
cid=15565
- 执行$result1) && isset($result1['series'][0]['name'] @1
- 执行$result2) && isset($result2['series'][0]['stack'] @1
- 执行$result3) && $result3['xAxis']['type'] == 'value @1
- 执行$result4) && isset($result4['series'][0]['data'][0] @1
- 执行$result5) && isset($result5['series'][0]['name'] @1
*/
// 1. 导入依赖
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
// 2. 用户登录
su('admin');
// 3. 创建测试实例
$chartTest = new chartTest();
// 4. 执行测试步骤(至少5个)
$result1 = $chartTest->genCluBarTest('normal');
$result2 = $chartTest->genCluBarTest('stackedBar');
$result3 = $chartTest->genCluBarTest('cluBarY');
$result4 = $chartTest->genCluBarTest('withFilters');
$result5 = $chartTest->genCluBarTest('withLangs');
r(is_array($result1) && isset($result1['series'][0]['name'])) && p() && e('1');
r(is_array($result2) && isset($result2['series'][0]['stack'])) && p() && e('1');
r(is_array($result3) && $result3['xAxis']['type'] == 'value') && p() && e('1');
r(is_array($result4) && isset($result4['series'][0]['data'][0])) && p() && e('1');
r(is_array($result5) && isset($result5['series'][0]['name'])) && p() && e('1');
-38
View File
@@ -1,38 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::genLineChart();
timeout=0
cid=15566
- 执行$result1
- 第series[0]条的type属性 @line
- 第xAxis条的type属性 @category
- 执行$result2['xAxis']['data'][0]) ? $result2['xAxis']['data'][0] : @2023-01-01
- 执行chartTest模块的genLineChartSeriesCountTest方法,参数是'multiSeries' @2
- 执行chartTest模块的genLineChartSeriesCountTest方法,参数是'empty' @0
- 执行chartTest模块的genLineChartSeriesCountTest方法,参数是'normal' @1
*/
// 1. 导入依赖
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
// 2. 用户登录
su('admin');
// 3. 创建测试实例
$chartTest = new chartTest();
// 4. 执行测试步骤(至少5个)
$result1 = $chartTest->genLineChartTest('normal');
$result2 = $chartTest->genLineChartTest('dateSort');
r($result1) && p('series[0]:type;xAxis:type') && e('line,category');
r(isset($result2['xAxis']['data'][0]) ? $result2['xAxis']['data'][0] : '') && p() && e('2023-01-01');
r($chartTest->genLineChartSeriesCountTest('multiSeries')) && p() && e('2');
r($chartTest->genLineChartSeriesCountTest('empty')) && p() && e('0');
r($chartTest->genLineChartSeriesCountTest('normal')) && p() && e('1');
-58
View File
@@ -1,58 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::genPie();
timeout=0
cid=15567
- 执行chartTest模块的genPieTest方法,参数是$fields, $settings, $normalSql, $filters, 'mysql')['series'][0]['data'] @3
- 执行chartTest模块的genPieTest方法,参数是$fields, $settings, $emptySql, $filters, 'mysql')['series'][0]['data'] @0
- 执行chartTest模块的genPieTest方法,参数是$fields, $settings, $largeSql, $filters, 'mysql')['series'][0]['data'] @51
- 执行chartTest模块的genPieTest方法,参数是$fields, $settings, $filterSql, $filtersWithData, 'mysql')['series'][0]['data'] @2
- 执行chartTest模块的genPieTest方法,参数是$fields, $settings, $normalSql, $filters, 'duckdb')['series'][0]['type'] @pie
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
su('admin');
$chartTest = new chartTest();
$fields = array(
'status' => array(
'type' => 'option',
'object' => 'bug',
'field' => 'status',
'name' => '状态'
)
);
$settings = array(
'group' => array(
array('field' => 'status', 'group' => '')
),
'metric' => array(
array('field' => 'id', 'valOrAgg' => 'count')
)
);
$normalSql = "SELECT 'active' as status, 15 as id UNION ALL SELECT 'resolved' as status, 8 as id UNION ALL SELECT 'closed' as status, 3 as id";
$emptySql = "SELECT 1 WHERE 1=0";
$largeSql = "SELECT 1 as id, 1 as count";
for($i = 2; $i <= 55; $i++) {
$largeSql .= " UNION ALL SELECT $i as id, 1 as count";
}
$filterSql = "SELECT '活动' as status, 10 as id UNION ALL SELECT '已解决' as status, 5 as id";
$filters = array();
$filtersWithData = array('status' => array('operator' => 'IN', 'value' => "('active', 'resolved')"));
r(count($chartTest->genPieTest($fields, $settings, $normalSql, $filters, 'mysql')['series'][0]['data'])) && p() && e('3');
r(count($chartTest->genPieTest($fields, $settings, $emptySql, $filters, 'mysql')['series'][0]['data'])) && p() && e('0');
r(count($chartTest->genPieTest($fields, $settings, $largeSql, $filters, 'mysql')['series'][0]['data'])) && p() && e('51');
r(count($chartTest->genPieTest($fields, $settings, $filterSql, $filtersWithData, 'mysql')['series'][0]['data'])) && p() && e('2');
r($chartTest->genPieTest($fields, $settings, $normalSql, $filters, 'duckdb')['series'][0]['type']) && p() && e('pie');
-29
View File
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::genRadar();
timeout=0
cid=15568
- 执行chartTest模块的genRadarTest方法,参数是'normal')['series']['data'] @1
- 执行chartTest模块的genRadarTest方法,参数是'multi')['series']['data'] @2
- 执行chartTest模块的genRadarTest方法,参数是'empty')['series']['data'] @0
- 执行chartTest模块的genRadarTest方法,参数是'filtered')['radar']['indicator'] @3
- 执行chartTest模块的genRadarTest方法,参数是'multilang')['series']['data'][0]['name'] @计数值(计数)
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
su('admin');
$chartTest = new chartTest();
r(count($chartTest->genRadarTest('normal')['series']['data'])) && p() && e('1');
r(count($chartTest->genRadarTest('multi')['series']['data'])) && p() && e('2');
r(count($chartTest->genRadarTest('empty')['series']['data'])) && p() && e('0');
r(count($chartTest->genRadarTest('filtered')['radar']['indicator'])) && p() && e('3');
r($chartTest->genRadarTest('multilang')['series']['data'][0]['name']) && p() && e('计数值(计数)');
-40
View File
@@ -1,40 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::genWaterpolo();
timeout=0
cid=15569
- 执行$result1
- 第series[0]条的type属性 @liquidFill
- 第tooltip条的show属性 @1
- 执行$result2['series'][0]['data'][0]) ? $result2['series'][0]['data'][0] : @0
- 执行$result3['series'][0]['data'][0]) ? $result3['series'][0]['data'][0] : @0.95
- 执行$result4['series'][0]['data'][0]) ? $result4['series'][0]['data'][0] : @0.05
- 执行$result5['series'][0]['data'][0]) ? $result5['series'][0]['data'][0] : @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
zenData('chart')->loadYaml('chart')->gen(50);
zenData('module')->loadYaml('module')->gen(27)->fixPath();
zenData('user')->gen(5);
su('admin');
$chart = new chartTest();
$result1 = $chart->genWaterpoloTest('normal');
$result2 = $chart->genWaterpoloTest('zeroPercent');
$result3 = $chart->genWaterpoloTest('highPercent');
$result4 = $chart->genWaterpoloTest('lowPercent');
$result5 = $chart->genWaterpoloTest('exactOne');
r($result1) && p('series[0]:type;tooltip:show') && e('liquidFill;1');
r(isset($result2['series'][0]['data'][0]) ? $result2['series'][0]['data'][0] : '') && p() && e('0');
r(isset($result3['series'][0]['data'][0]) ? $result3['series'][0]['data'][0] : '') && p() && e('0.95');
r(isset($result4['series'][0]['data'][0]) ? $result4['series'][0]['data'][0] : '') && p() && e('0.05');
r(isset($result5['series'][0]['data'][0]) ? $result5['series'][0]['data'][0] : '') && p() && e('1');
@@ -1,30 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::getDefaultCharts();
timeout=0
cid=15571
- 测试传入的分组是子分组时,返回空数据 @0
- 测试查询不存在的分组 @0
- 获取组织分组下第一个图表的当前分组ID、ID、名称
- 第0条的currentGroup属性 @45
- 第0条的id属性 @45
- 第0条的name属性 @图表45
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
zenData('chart')->loadYaml('chart')->gen(50);
zenData('module')->loadYaml('module')->gen(27)->fixPath();
zenData('user')->gen(5);
su('admin');
global $tester;
$chart = $tester->loadModel('chart');
r($chart->getDefaultCharts(36)) && p() && e('0'); //测试传入的分组是子分组时,返回空数据
r($chart->getDefaultCharts(123)) && p() && e('0'); //测试查询不存在的分组
r($chart->getDefaultCharts(35)) && p('0:currentGroup,id,name') && e('45,45,图表45'); //获取组织分组下第一个图表的当前分组ID、ID、名称
@@ -1,65 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 biModel::getEchartOptions();
timeout=0
cid=15572
- 查询获取到的所有属性第0条的name属性 @5
- 查询结果中的gird
- 第grid条的left属性 @3%
- 第grid条的right属性 @4%
- 查询结果中的xAxis第xAxis条的type属性 @category
- 查询结果中的yAxis第yAxis条的type属性 @value
- 查询结果中的tooltip第tooltip条的trigger属性 @axis
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
su('admin');
zenData('action')->gen(500);
zenData('project')->gen(100);
global $tester;
$tester->loadModel('chart');
$chart = new stdclass();
$chart->id = 1080;
$chart->name = '年度新增-项目年度新增和完成趋势图';
$chart->code = 'annualCreated_projectTendency';
$chart->driver = 'mysql';
$chart->mode = 'text';
$chart->dimension = 1;
$chart->type = 'line';
$chart->group = 38;
$chart->dataset = 0;
$chart->desc = '';
$chart->acl = 'open';
$chart->whitelist = '';
$chart->settings = array(0 => array('type' => 'line', 'xaxis' => array( 0 => array ( 'field' => 'YEARMONTH', 'name' => 'YEARMONTH', 'group' => '', ), ), 'yaxis' => array ( 0 => array ( 'field' => 'newProject', 'name' => 'newProject', 'valOrAgg' => 'sum', ), 1 => array ( 'field' => 'closedProject', 'name' => '已关闭的项目', 'valOrAgg' => 'sum'))));
$chart->filters = array();
$chart->fields = array();
$chart->langs = array();
$chart->sql = 'SELECT YEARMONTH, t1.year, CONCAT(t1.month, "月") AS `month`, IFNULL(t2.project, 0) AS newProject, IFNULL(t3.project, 0) AS closedProject FROM (SELECT DISTINCT DATE_FORMAT(date, \'%Y-%m\') YEARMONTH, Year(date) AS `year`, MONTH(date) AS `month` FROM zt_action) AS t1 LEFT JOIN (SELECT YEAR(openedDate) AS `year`, MONTH(openedDate) AS `month`, COUNT(1) AS project FROM zt_project WHERE deleted = \'0\' AND type = \'project\' GROUP BY `year`, `month`) AS t2 ON t1.year = t2.year AND t1.month = t2.month LEFT JOIN (SELECT YEAR(closedDate) AS `year`, MONTH(closedDate) AS `month`, COUNT(1) AS project FROM zt_project WHERE deleted = \'0\' AND type = \'project\' AND status = \'closed\' GROUP BY `year`, `month`) AS t3 ON t1.year = t3.year AND t1.month = t3.month ORDER BY `year`, t1.month';
$chart->version = '1';
$chart->stage = 'published';
$chart->builtin = 0;
$chart->objects = '';
$chart->createdBy = 'system';
$chart->createdDate = '2025-06-16 11:25:41';
$chart->editedBy = '';
$chart->editedDate = '';
$chart->deleted = 0;
$chart->fieldSettings = array('YEARMONTH' => array ( 'name' => 'YEARMONTH', 'object' => 'project', 'field' => 'YEARMONTH', 'type' => 'string', ), 'year' => array ( 'name' => 'year', 'object' => 'project', 'field' => 'year', 'type' => 'number', ), 'month' => array ( 'name' => 'month', 'object' => 'project', 'field' => 'month', 'type' => 'string', ), 'newProject' => array ( 'name' => 'newProject', 'object' => 'project', 'field' => 'newProject', 'type' => 'string', ), 'closedProject' => array ( 'name' => '已关闭的项目', 'object' => 'project', 'field' => 'closedProject', 'type' => 'string'));
$chart->currentGroup = 38;
$result = $tester->chart->getEchartOptions($chart);
r(count($result)) && p('0:name') && e('5'); // 查询获取到的所有属性
r($result) && p('grid:left,right') && e('3%,4%'); // 查询结果中的gird
r($result) && p('xAxis:type') && e('category'); // 查询结果中的xAxis
r($result) && p('yAxis:type') && e('value'); // 查询结果中的yAxis
r($result) && p('tooltip:trigger') && e('axis'); // 查询结果中的tooltip
@@ -1,85 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::getFilterFormat();
timeout=0
cid=15573
- 测试没有default的情况 @0
- 测试default为空的情况 @0
- 测试select
- 第year条的operator属性 @IN
- 第year条的value属性 @('2023')
- 测试input
- 第project条的operator属性 @like
- 第project条的value属性 @'%1%'
- 测试date没有begin和end @0
- 测试input
- 第openedDate条的operator属性 @BETWEEN
- 第openedDate条的value属性 @'2023-01-01 00:00:00' and '2023-02-01 23:59:59'
- 测试is not null
- 第id条的operator属性 @IS NOT NULL
- 第id条的value属性 @N/A
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
zenData('user')->gen(5);
su('admin');
$testNoDefault = array();
$testNoDefault['field'] = 'id';
$testNoDefault['type'] = 'input';
$selectEmptyDefault = array();
$selectEmptyDefault['field'] = 'year';
$selectEmptyDefault['type'] = 'select';
$selectEmptyDefault['default'] = '';
$selectFilter = array();
$selectFilter['field'] = 'year';
$selectFilter['type'] = 'select';
$selectFilter['default'] = '2023';
$inputFilter = array();
$inputFilter['field'] = 'project';
$inputFilter['type'] = 'input';
$inputFilter['default'] = '1';
$emptyDateFilter = array();
$emptyDateFilter['field'] = 'openedDate';
$emptyDateFilter['type'] = 'date';
$emptyDateFilter['default'] = array('begin' => '', 'end' => '');
$dateFilter = array();
$dateFilter['field'] = 'openedDate';
$dateFilter['type'] = 'date';
$dateFilter['default'] = array('begin' => '2023-01-01', 'end' => '2023-02-01');
$inFilter = array();
$inFilter['field'] = 'id';
$inFilter['type'] = 'condition';
$inFilter['operator'] = 'IN';
$inFilter['value'] = '1,2,3';
$notNullFilter = array();
$notNullFilter['field'] = 'id';
$notNullFilter['type'] = 'condition';
$notNullFilter['operator'] = 'IS NOT NULL';
$notNullFilter['value'] = '';
global $tester;
$chart = $tester->loadModel('chart');
r($chart->getFilterFormat(array($testNoDefault))) && p() && e('0'); //测试没有default的情况
r($chart->getFilterFormat(array($selectEmptyDefault))) && p() && e('0'); //测试default为空的情况
r($chart->getFilterFormat(array($selectFilter))) && p('year:operator,value') && e("IN,('2023')"); //测试select
r($chart->getFilterFormat(array($inputFilter))) && p('project:operator,value') && e("like,'%1%'"); //测试input
r($chart->getFilterFormat(array($emptyDateFilter))) && p('') && e('0'); //测试date没有begin和end
r($chart->getFilterFormat(array($dateFilter))) && p('openedDate:operator,value') && e("BETWEEN,'2023-01-01 00:00:00' and '2023-02-01 23:59:59'"); //测试input
r($chart->getFilterFormat(array($notNullFilter))) && p('id:operator,value') && e('IS NOT NULL,~~'); //测试is not null
-47
View File
@@ -1,47 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::getFirstGroup();
timeout=0
cid=15574
- 执行chartTest模块的getFirstGroupTest方法,参数是1 @1
- 执行chartTest模块的getFirstGroupTest方法,参数是2 @32
- 执行chartTest模块的getFirstGroupTest方法,参数是999 @0
- 执行chartTest模块的getFirstGroupTest方法 @0
- 执行chartTest模块的getFirstGroupTest方法,参数是-1 @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
// 直接插入测试数据而不使用zenData
global $tester;
$dao = $tester->dao;
// 清理测试数据
$dao->delete()->from(TABLE_MODULE)->where('type')->eq('chart')->exec();
// 插入测试数据
$modules = array(
array('id' => 1, 'root' => 1, 'branch' => 0, 'name' => '图表分组1', 'parent' => 0, 'path' => ',1,', 'grade' => 1, 'order' => 10, 'type' => 'chart', 'owner' => 'admin', 'collector' => '', 'short' => 'chart1', 'deleted' => '0'),
array('id' => 2, 'root' => 1, 'branch' => 0, 'name' => '图表分组2', 'parent' => 0, 'path' => ',2,', 'grade' => 1, 'order' => 20, 'type' => 'chart', 'owner' => 'admin', 'collector' => '', 'short' => 'chart2', 'deleted' => '0'),
array('id' => 32, 'root' => 2, 'branch' => 0, 'name' => '图表分组32', 'parent' => 0, 'path' => ',32,', 'grade' => 1, 'order' => 10, 'type' => 'chart', 'owner' => 'admin', 'collector' => '', 'short' => 'chart32', 'deleted' => '0')
);
foreach($modules as $module) {
$dao->insert(TABLE_MODULE)->data($module)->exec();
}
su('admin');
$chartTest = new chartTest();
r($chartTest->getFirstGroupTest(1)) && p() && e('1');
r($chartTest->getFirstGroupTest(2)) && p() && e('32');
r($chartTest->getFirstGroupTest(999)) && p() && e('0');
r($chartTest->getFirstGroupTest(0)) && p() && e('0');
r($chartTest->getFirstGroupTest(-1)) && p() && e('0');
-70
View File
@@ -1,70 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::getMultiData();
timeout=0
cid=15575
- 步骤1:正常情况 @status
- 步骤2:多指标第1条的0属性 @id
- 步骤3:带过滤器第3条的0属性 @core
- 步骤4:带排序第3条的0属性 @bug
- 步骤5:日期分组第3条的0属性 @2022
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
// 2. zendata数据准备(根据需要配置)
// 由于getMultiData方法在测试类中是模拟数据,不需要实际数据库数据
// 3. 用户登录(选择合适角色)
// su('admin'); // 模拟测试不需要登录
// 4. 创建测试实例(变量名与模块名一致)
$chartTest = new chartTest();
// 5. 🔴 强制要求:必须包含至少5个测试步骤
// 步骤1:正常单指标数据获取
$settings1 = array(
'xaxis' => array(array('field' => 'status', 'name' => '状态', 'group' => '')),
'yaxis' => array(array('field' => 'id', 'name' => '数量', 'valOrAgg' => 'count'))
);
r($chartTest->getMultiDataTest($settings1)) && p('0') && e('status'); // 步骤1:正常情况
// 步骤2:多指标数据获取
$settings2 = array(
'xaxis' => array(array('field' => 'priority', 'name' => '优先级', 'group' => '')),
'yaxis' => array(
array('field' => 'id', 'name' => '数量', 'valOrAgg' => 'count'),
array('field' => 'estimate', 'name' => '工时', 'valOrAgg' => 'sum')
)
);
r($chartTest->getMultiDataTest($settings2)) && p('1:0') && e('id'); // 步骤2:多指标
// 步骤3:带过滤器的数据获取
$settings3 = array(
'xaxis' => array(array('field' => 'module', 'name' => '模块', 'group' => '')),
'yaxis' => array(array('field' => 'id', 'name' => '数量', 'valOrAgg' => 'count'))
);
$filters3 = array('product' => array('operator' => '=', 'value' => '1'));
r($chartTest->getMultiDataTest($settings3, '', $filters3)) && p('3:0') && e('core'); // 步骤3:带过滤器
// 步骤4:带排序的数据获取
$settings4 = array(
'xaxis' => array(array('field' => 'type', 'name' => '类型', 'group' => '')),
'yaxis' => array(array('field' => 'id', 'name' => '数量', 'valOrAgg' => 'count'))
);
r($chartTest->getMultiDataTest($settings4, '', array(), 'mysql', true)) && p('3:0') && e('bug'); // 步骤4:带排序
// 步骤5:日期分组数据获取
$settings5 = array(
'xaxis' => array(array('field' => 'openedDate', 'name' => '创建日期', 'group' => 'YEAR')),
'yaxis' => array(array('field' => 'id', 'name' => '数量', 'valOrAgg' => 'count'))
);
r($chartTest->getMultiDataTest($settings5)) && p('3:0') && e('2022'); // 步骤5:日期分组
-41
View File
@@ -1,41 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::getSysOptions();
timeout=0
cid=15576
- 测试参数全部为空 @0
- 测试查询用户属性admin @admin
- 测试查询产品属性1 @正常产品1
- 测试查询项目属性11 @项目11
- 测试查询部门属性1 @/产品部1
- 测试查询bug状态属性active @激活
- 测试查询bug名称属性1 @BUG1
- 测试使用sql查询属性BUG1 @BUG1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
zenData('user')->gen(5);
zenData('product')->gen(5);
zenData('project')->gen(20);
zenData('dept')->gen(5);
zenData('bug')->gen(5);
su('admin');
global $tester;
$chart = $tester->loadModel('chart');
r($chart->getSysOptions('', '', '', '')) && p() && e('0'); //测试参数全部为空
r($chart->getSysOptions('user', '', '', '')) && p('admin') && e('admin'); //测试查询用户
r($chart->getSysOptions('product', '', '', '')) && p('1') && e('正常产品1'); //测试查询产品
r($chart->getSysOptions('project', '', '', '')) && p('11') && e('项目11'); //测试查询项目
r($chart->getSysOptions('dept', '', '', '')) && p('1') && e('/产品部1'); //测试查询部门
r($chart->getSysOptions('option', 'bug', 'status', '')) && p('active') && e('激活'); //测试查询bug状态
r($chart->getSysOptions('object', 'bug', 'title', '')) && p('1') && e('BUG1'); //测试查询bug名称
r($chart->getSysOptions('string', '', 'title', 'select * from zt_bug')) && p('BUG1') && e('BUG1'); //测试使用sql查询
-33
View File
@@ -1,33 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::getTreeMenu();
timeout=0
cid=15577
- 测试ID为0时是否返回空 @0
- 测试传入子分组时是否返回空 @0
- 测试获取的分组为空 @0
- 测试产品分组下的图表树
- 第1条的id属性 @37_37
- 第1条的parent属性 @37
- 第1条的name属性 @图表37
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
zenData('chart')->loadYaml('chart')->gen(50);
zenData('module')->loadYaml('module')->gen(27)->fixPath();
zenData('user')->gen(5);
su('admin');
global $tester;
$chart = $tester->loadModel('chart');
r($chart->getTreeMenu(0)) && p() && e('0'); //测试ID为0时是否返回空
r($chart->getTreeMenu(36)) && p() && e('0'); //测试传入子分组时是否返回空
r($chart->getTreeMenu(30)) && p() && e('0'); //测试获取的分组为空
r($chart->getTreeMenu(32)) && p("1:id,parent,name") && e("37_37,37,图表37"); //测试产品分组下的图表树
-31
View File
@@ -1,31 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::processChart();
timeout=0
cid=15580
- 测试解密langs字段第langs[name]条的zh-cn属性 @项目名称
- 测试解密filters字段第filters[0]条的field属性 @closedDate
- 测试解密settings字段第settings[0]条的type属性 @cluBarY
- 测试sql字段为null的情况属性sql @~~
- 测试sql字段为null的情况属性sql @SELECT id FROM zt_project WHERE type='program' AND parent=0 AND deleted='0'
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
zenData('chart')->loadYaml('chart')->gen(50);
zenData('module')->loadYaml('module')->gen(27)->fixPath();
zenData('user')->gen(5);
su('admin');
$chart = new chartTest();
r($chart->processChartTest('decodeLangs')) && p('langs[name]:zh-cn') && e('项目名称'); //测试解密langs字段
r($chart->processChartTest('decodeFilters')) && p('filters[0]:field') && e('closedDate'); //测试解密filters字段
r($chart->processChartTest('decodeSettings')) && p('settings[0]:type') && e('cluBarY'); //测试解密settings字段
r($chart->processChartTest('sqlNull')) && p('sql') && e('~~'); //测试sql字段为null的情况
r($chart->processChartTest('trimSQL')) && p('sql') && e("SELECT id FROM zt_project WHERE type='program' AND parent=0 AND deleted='0'"); //测试sql字段为null的情况
-98
View File
@@ -1,98 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::getRows();
timeout=0
cid=15581
- 测试筛选器为空,所属产品为组,以ID去重后计数为条件查询的需求数据
- 第0条的product属性 @1
- 第0条的id属性 @4
- 测试筛选ID小于3,所属产品为组,以ID去重后计数为条件查询的需求数据
- 第0条的product属性 @1
- 第0条的id属性 @2
- 测试筛选status等于active,所属产品为组,以ID去重后计数为条件查询的需求数据
- 第1条的product属性 @2
- 第1条的id属性 @1
- 测试筛选器为空,创建日期按月分组,以ID去重后计数为条件查询的需求数据
- 第0条的ttyear属性 @2022
- 第0条的ttgroup属性 @1
- 第0条的id属性 @5
- 测试筛选器为空,创建日期按年分组,以ID去重后计数为条件查询的需求数据
- 第0条的openedDate属性 @2022
- 第0条的id属性 @25
- 测试筛选器为空,创建日期按周分组,以ID去重后计数为条件查询的需求数据
- 第1条的openedDate属性 @202201
- 第1条的id属性 @4
- 测试筛选器为空,创建日期按日为组,以ID去重后计数为条件查询的需求数据
- 第2条的openedDate属性 @2022-01-03
- 第2条的id属性 @1
- 测试筛选器为空,所属产品为组,以ID计数为条件查询的需求数据
- 第0条的product属性 @1
- 第0条的id属性 @4
- 测试筛选器为空,所属产品为组,以ID求和为条件查询的需求数据
- 第0条的product属性 @1
- 第0条的id属性 @10.00
- 测试筛选器为空,所属产品为组,以ID求平均值为条件查询的需求数据
- 第0条的product属性 @1
- 第0条的id属性 @2.50
- 测试筛选器为空,所属产品为组,以ID求最大值为条件查询的需求数据
- 第0条的product属性 @1
- 第0条的id属性 @4
- 测试筛选器为空,所属产品为组,以ID求最小值为条件查询的需求数据
- 第0条的product属性 @1
- 第0条的id属性 @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
zenData('story')->loadYaml('story')->gen(50);
zenData('user')->gen(5);
su('admin');
$defaultSql = 'SELECT * FROM zt_story';
$emptyFilters = array();
$filters = array();
$filters[0]['id'] = array('operator' => '<', 'value' => '3');
$filters[1]['status'] = array('operator' => '=', 'value' => "'active'");
$date = array();
$date[''] = '';
$date['MONTH'] = 'MONTH';
$date['YEAR'] = 'YEAR';
$date['WEEK'] = 'YEARWEEK';
$date['DATE'] = 'DATE';
$group = array();
$group['product'] = 'product';
$group['openedDate'] = 'openedDate';
$agg = array();
$agg['distinct'] = 'distinct';
$agg['count'] = 'count';
$agg['sum'] = 'sum';
$agg['avg'] = 'avg';
$agg['max'] = 'max';
$agg['min'] = 'min';
global $tester;
$chart = $tester->loadModel('chart');
r($chart->getRows($defaultSql, $emptyFilters, $date[''], $group['product'], 'id', $agg['distinct'])) && p('0:product,id') && e('1,4'); //测试筛选器为空,所属产品为组,以ID去重后计数为条件查询的需求数据
r($chart->getRows($defaultSql, $filters[0], $date[''], $group['product'], 'id', $agg['distinct'])) && p('0:product,id') && e('1,2'); //测试筛选ID小于3,所属产品为组,以ID去重后计数为条件查询的需求数据
r($chart->getRows($defaultSql, $filters[1], $date[''], $group['product'], 'id', $agg['distinct'])) && p('1:product,id') && e('2,1'); //测试筛选status等于active,所属产品为组,以ID去重后计数为条件查询的需求数据
r($chart->getRows($defaultSql, $emptyFilters, $date['MONTH'], $group['openedDate'], 'id', $agg['distinct'])) && p('0:ttyear,ttgroup,id') && e('2022,1,5'); //测试筛选器为空,创建日期按月分组,以ID去重后计数为条件查询的需求数据
r($chart->getRows($defaultSql, $emptyFilters, $date['YEAR'], $group['openedDate'], 'id', $agg['distinct'])) && p('0:openedDate,id') && e('2022,25'); //测试筛选器为空,创建日期按年分组,以ID去重后计数为条件查询的需求数据
r($chart->getRows($defaultSql, $emptyFilters, $date['WEEK'], $group['openedDate'], 'id', $agg['distinct'])) && p('1:openedDate,id') && e('202201,4'); //测试筛选器为空,创建日期按周分组,以ID去重后计数为条件查询的需求数据
r($chart->getRows($defaultSql, $emptyFilters, $date['DATE'], $group['openedDate'], 'id', $agg['distinct'])) && p('2:openedDate,id') && e('2022-01-03,1'); //测试筛选器为空,创建日期按日为组,以ID去重后计数为条件查询的需求数据
r($chart->getRows($defaultSql, $emptyFilters, $date[''], $group['product'], 'id', $agg['count'])) && p('0:product,id') && e('1,4'); //测试筛选器为空,所属产品为组,以ID计数为条件查询的需求数据
r($chart->getRows($defaultSql, $emptyFilters, $date[''], $group['product'], 'id', $agg['sum'])) && p('0:product,id') && e('1,10.00'); //测试筛选器为空,所属产品为组,以ID求和为条件查询的需求数据
r($chart->getRows($defaultSql, $emptyFilters, $date[''], $group['product'], 'id', $agg['avg'])) && p('0:product,id') && e('1,2.50'); //测试筛选器为空,所属产品为组,以ID求平均值为条件查询的需求数据
r($chart->getRows($defaultSql, $emptyFilters, $date[''], $group['product'], 'id', $agg['max'])) && p('0:product,id') && e('1,4'); //测试筛选器为空,所属产品为组,以ID求最大值为条件查询的需求数据
r($chart->getRows($defaultSql, $emptyFilters, $date[''], $group['product'], 'id', $agg['min'])) && p('0:product,id') && e('1,1'); //测试筛选器为空,所属产品为组,以ID求最小值为条件查询的需求数据
-90
View File
@@ -1,90 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartModel::processRows();
timeout=0
cid=15582
- 测试2022年1月份的需求数属性2022-01 @5
- 测试2022年2月份的需求数属性2022-02 @5
- 测试2022年3月份的需求数属性2022-03 @5
- 测试2022年4月份的需求数属性2022-04 @5
- 测试2022年5月份的需求数属性2022-05 @5
- 测试2023年1月份的需求数属性2023-01 @5
- 测试2023年2月份的需求数属性2023-02 @5
- 测试2023年3月份的需求数属性2023-03 @5
- 测试2024年1月份的需求数属性2024-01 @5
- 测试2024年2月份的需求数属性2024-02 @5
- 测试2022年的需求数属性2022 @25
- 测试2023年的需求数属性2023 @15
- 测试2024年的需求数属性2024 @10
- 测试2021年第52周的需求数属性2021年第52周 @1
- 测试2022年第01周的需求数属性2022年第01周 @4
- 测试2022年第05周的需求数属性2022年第05周 @5
- 测试2022年第09周的需求数属性2022年第09周 @5
- 测试2022年第13周的需求数属性2022年第13周 @5
- 测试2022年第18周的需求数属性2022年第18周 @5
- 测试2023年第01周的需求数属性2023年第01周 @5
- 测试2023年第05周的需求数属性2023年第05周 @5
- 测试2023年第09周的需求数属性2023年第09周 @5
- 测试2022-01-01的需求数属性2022-01-01 @1
- 测试2022-01-02的需求数属性2022-01-02 @1
- 测试2022-01-03的需求数属性2022-01-03 @1
- 测试2022-01-04的需求数属性2022-01-04 @1
- 测试2022-01-05的需求数属性2022-01-05 @1
- 测试2022-02-01的需求数属性2022-02-01 @5
- 测试2022-03-01的需求数属性2022-03-01 @5
- 测试2022-04-01的需求数属性2022-04-01 @5
- 测试2022-05-01的需求数属性2022-05-01 @5
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
zenData('story')->loadYaml('story')->gen(50);
zenData('user')->gen(5);
su('admin');
$date = array();
$date['MONTH'] = 'MONTH';
$date['YEAR'] = 'YEAR';
$date['WEEK'] = 'YEARWEEK';
$date['DATE'] = 'DATE';
$chart = new chartTest();
r($chart->processRowsTest($date['MONTH'], 'openedDate', 'id')) && p('2022-01') && e('5'); //测试2022年1月份的需求数
r($chart->processRowsTest($date['MONTH'], 'openedDate', 'id')) && p('2022-02') && e('5'); //测试2022年2月份的需求数
r($chart->processRowsTest($date['MONTH'], 'openedDate', 'id')) && p('2022-03') && e('5'); //测试2022年3月份的需求数
r($chart->processRowsTest($date['MONTH'], 'openedDate', 'id')) && p('2022-04') && e('5'); //测试2022年4月份的需求数
r($chart->processRowsTest($date['MONTH'], 'openedDate', 'id')) && p('2022-05') && e('5'); //测试2022年5月份的需求数
r($chart->processRowsTest($date['MONTH'], 'openedDate', 'id')) && p('2023-01') && e('5'); //测试2023年1月份的需求数
r($chart->processRowsTest($date['MONTH'], 'openedDate', 'id')) && p('2023-02') && e('5'); //测试2023年2月份的需求数
r($chart->processRowsTest($date['MONTH'], 'openedDate', 'id')) && p('2023-03') && e('5'); //测试2023年3月份的需求数
r($chart->processRowsTest($date['MONTH'], 'openedDate', 'id')) && p('2024-01') && e('5'); //测试2024年1月份的需求数
r($chart->processRowsTest($date['MONTH'], 'openedDate', 'id')) && p('2024-02') && e('5'); //测试2024年2月份的需求数
r($chart->processRowsTest($date['YEAR'], 'openedDate', 'id')) && p('2022') && e('25'); //测试2022年的需求数
r($chart->processRowsTest($date['YEAR'], 'openedDate', 'id')) && p('2023') && e('15'); //测试2023年的需求数
r($chart->processRowsTest($date['YEAR'], 'openedDate', 'id')) && p('2024') && e('10'); //测试2024年的需求数
r($chart->processRowsTest($date['WEEK'], 'openedDate', 'id')) && p('2021年第52周') && e('1'); //测试2021年第52周的需求数
r($chart->processRowsTest($date['WEEK'], 'openedDate', 'id')) && p('2022年第01周') && e('4'); //测试2022年第01周的需求数
r($chart->processRowsTest($date['WEEK'], 'openedDate', 'id')) && p('2022年第05周') && e('5'); //测试2022年第05周的需求数
r($chart->processRowsTest($date['WEEK'], 'openedDate', 'id')) && p('2022年第09周') && e('5'); //测试2022年第09周的需求数
r($chart->processRowsTest($date['WEEK'], 'openedDate', 'id')) && p('2022年第13周') && e('5'); //测试2022年第13周的需求数
r($chart->processRowsTest($date['WEEK'], 'openedDate', 'id')) && p('2022年第18周') && e('5'); //测试2022年第18周的需求数
r($chart->processRowsTest($date['WEEK'], 'openedDate', 'id')) && p('2023年第01周') && e('5'); //测试2023年第01周的需求数
r($chart->processRowsTest($date['WEEK'], 'openedDate', 'id')) && p('2023年第05周') && e('5'); //测试2023年第05周的需求数
r($chart->processRowsTest($date['WEEK'], 'openedDate', 'id')) && p('2023年第09周') && e('5'); //测试2023年第09周的需求数
r($chart->processRowsTest($date['DATE'], 'openedDate', 'id')) && p('2022-01-01') && e('1'); //测试2022-01-01的需求数
r($chart->processRowsTest($date['DATE'], 'openedDate', 'id')) && p('2022-01-02') && e('1'); //测试2022-01-02的需求数
r($chart->processRowsTest($date['DATE'], 'openedDate', 'id')) && p('2022-01-03') && e('1'); //测试2022-01-03的需求数
r($chart->processRowsTest($date['DATE'], 'openedDate', 'id')) && p('2022-01-04') && e('1'); //测试2022-01-04的需求数
r($chart->processRowsTest($date['DATE'], 'openedDate', 'id')) && p('2022-01-05') && e('1'); //测试2022-01-05的需求数
r($chart->processRowsTest($date['DATE'], 'openedDate', 'id')) && p('2022-02-01') && e('5'); //测试2022-02-01的需求数
r($chart->processRowsTest($date['DATE'], 'openedDate', 'id')) && p('2022-03-01') && e('5'); //测试2022-03-01的需求数
r($chart->processRowsTest($date['DATE'], 'openedDate', 'id')) && p('2022-04-01') && e('5'); //测试2022-04-01的需求数
r($chart->processRowsTest($date['DATE'], 'openedDate', 'id')) && p('2022-05-01') && e('5'); //测试2022-05-01的需求数
-93
View File
@@ -1,93 +0,0 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartTao::switchFieldName();
timeout=0
cid=15583
- 执行chartTest模块的switchFieldNameTest方法,参数是$fields1, $langs1, $metrics1, '0' @状态字段
- 执行chartTest模块的switchFieldNameTest方法,参数是$fields2, $langs2, $metrics2, '0' @Bug状态
- 执行chartTest模块的switchFieldNameTest方法,参数是$fields3, $langs3, $metrics3, '0' @中文任务名称
- 执行chartTest模块的switchFieldNameTest方法,参数是$fields4, $langs4, $metrics4, '0' @空字段配置
- 执行chartTest模块的switchFieldNameTest方法,参数是$fields5, $langs5, $metrics5, '0' @项目名称中文
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/chart.unittest.class.php';
su('admin');
$chartTest = new chartTest();
// 测试步骤1:基本字段名称获取
$fields1 = array(
'status' => array('name' => '状态字段'),
'priority' => array('name' => '优先级字段')
);
$langs1 = array();
$metrics1 = array('status', 'priority');
r($chartTest->switchFieldNameTest($fields1, $langs1, $metrics1, '0')) && p() && e('状态字段');
// 测试步骤2:关联对象字段名称转换
$fields2 = array(
'bugStatus' => array(
'name' => '默认状态名',
'object' => 'bug',
'field' => 'status'
)
);
$langs2 = array();
$metrics2 = array('bugStatus');
r($chartTest->switchFieldNameTest($fields2, $langs2, $metrics2, '0')) && p() && e('Bug状态');
// 测试步骤3:客户端语言优先级
$fields3 = array(
'taskName' => array(
'name' => '默认任务名',
'object' => 'task',
'field' => 'name'
)
);
$langs3 = array(
'taskName' => array(
'zh-cn' => '中文任务名称',
'en' => 'English Task Name'
)
);
$metrics3 = array('taskName');
r($chartTest->switchFieldNameTest($fields3, $langs3, $metrics3, '0')) && p() && e('中文任务名称');
// 测试步骤4:空语言配置处理
$fields4 = array(
'emptyField' => array(
'name' => '空字段配置',
'object' => 'nonexistent',
'field' => 'nonexistent'
)
);
$langs4 = array();
$metrics4 = array('emptyField');
r($chartTest->switchFieldNameTest($fields4, $langs4, $metrics4, '0')) && p() && e('空字段配置');
// 测试步骤5:复杂场景综合测试
$fields5 = array(
'complexField' => array(
'name' => '默认字段名',
'object' => 'project',
'field' => 'name'
),
'simpleField' => array(
'name' => '简单字段名'
)
);
$langs5 = array(
'complexField' => array(
'zh-cn' => '项目名称中文',
'en' => 'Project Name EN'
)
);
$metrics5 = array('complexField', 'simpleField');
r($chartTest->switchFieldNameTest($fields5, $langs5, $metrics5, '0')) && p() && e('项目名称中文');