+ [misc] Add unit tests for chartZen::getChartToFilter() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-11-12 08:25:39 +08:00
co-authored by Claude
parent 2266c83d85
commit cddaad3cca
3 changed files with 240 additions and 0 deletions
+16
View File
@@ -21,4 +21,20 @@ class chartZenTest extends baseTest
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test getChartToFilter method.
*
* @param int $groupID
* @param int $chartID
* @param array $filterValues
* @access public
* @return object|null|string
*/
public function getChartToFilterTest(int $groupID = 0, int $chartID = 0, array $filterValues = array())
{
$result = $this->invokeArgs('getChartToFilter', array($groupID, $chartID, $filterValues));
if(dao::isError()) return dao::getError();
return $result;
}
}
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env php
<?php
/**
title=测试 chartZen::getChartToFilter();
timeout=0
cid=0
- 执行chartTest模块的getChartToFilterTest方法,参数是5, 1, array
- 属性id @1
- 属性currentGroup @5
- 执行chartTest模块的getChartToFilterTest方法,参数是5, 999, array @0
- 执行chartTest模块的getChartToFilterTest方法,参数是0, 3, array
- 属性id @3
- 属性currentGroup @0
- 执行chartTest模块的getChartToFilterTest方法,参数是5, 1, array 属性id @1
- 执行chartTest模块的getChartToFilterTest方法,参数是5, 2, array 属性id @2
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/zen.class.php';
zendata('chart')->loadYaml('getcharttofilter', false, 2)->gen(10);
su('admin');
$chartTest = new chartZenTest();
r($chartTest->getChartToFilterTest(5, 1, array())) && p('id,currentGroup') && e('1,5');
r($chartTest->getChartToFilterTest(5, 999, array())) && p() && e('0');
r($chartTest->getChartToFilterTest(0, 3, array())) && p('id,currentGroup') && e('3,0');
r($chartTest->getChartToFilterTest(5, 1, array('status' => 'active'))) && p('id') && e('1');
r($chartTest->getChartToFilterTest(5, 2, array('status' => 'closed', 'priority' => '3'))) && p('id') && e('2');
@@ -0,0 +1,189 @@
---
title: 图表数据定义
desc: 用于测试getChartToFilter方法的图表数据
author: Claude
version: 1.0
fields:
- field: id
note: 图表ID
range: 1-10
prefix: ""
postfix: ""
loop: 0
format: ""
- field: name
note: 图表名称
range: 测试图表1,测试图表2,测试图表3,测试图表4,测试图表5,测试图表6,测试图表7,测试图表8,测试图表9,测试图表10
prefix: ""
postfix: ""
loop: 0
format: ""
- field: code
note: 图表代码
range: chart1,chart2,chart3,chart4,chart5,chart6,chart7,chart8,chart9,chart10
prefix: ""
postfix: ""
loop: 0
format: ""
- field: driver
note: 数据驱动类型
range: mysql{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: mode
note: 模式
range: builder{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: dimension
note: 维度
range: 1-10
prefix: ""
postfix: ""
loop: 0
format: ""
- field: type
note: 图表类型
range: line{3},bar{3},pie{2},radar{2}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: group
note: 分组
range: 1,2,3,4,5,6,7,8,9,10
prefix: ""
postfix: ""
loop: 0
format: ""
- field: dataset
note: 数据集
range: 0{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: desc
note: 描述
range: 这是一个测试图表{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: acl
note: 访问控制
range: open{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: whitelist
note: 白名单
range: []{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: settings
note: 设置
range: '{}'{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: filters
note: 过滤器
range: '{"status":{"default":"open"},"priority":{"default":"1"}}','{"type":{"default":"bug"}}'{'{}'{8}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: step
note: 步骤
range: 0{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: fields
note: 字段
range: '{}'{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: langs
note: 语言
range: '{}'{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: sql
note: SQL语句
range: SELECT 1{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: version
note: 版本
range: 1{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: stage
note: 阶段
range: published{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: builtin
note: 是否内置
range: 0{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: deleted
note: 是否删除
range: 0{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: createdBy
note: 创建人
range: admin{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: createdDate
note: 创建时间
range: 2024-01-01 10:00:00{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: editedBy
note: 编辑人
range: []{10}
prefix: ""
postfix: ""
loop: 0
format: ""
- field: editedDate
note: 编辑时间
range: 0000-00-00 00:00:00{10}
prefix: ""
postfix: ""
loop: 0
format: ""