From cddaad3cca70e709adc90d1143b60c733833db2a Mon Sep 17 00:00:00 2001 From: liugang Date: Sat, 8 Nov 2025 02:25:06 +0800 Subject: [PATCH] + [misc] Add unit tests for chartZen::getChartToFilter() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- module/chart/test/lib/zen.class.php | 16 ++ module/chart/test/zen/getcharttofilter.php | 35 ++++ .../test/zen/yaml/getcharttofilter/chart.yaml | 189 ++++++++++++++++++ 3 files changed, 240 insertions(+) create mode 100755 module/chart/test/zen/getcharttofilter.php create mode 100644 module/chart/test/zen/yaml/getcharttofilter/chart.yaml diff --git a/module/chart/test/lib/zen.class.php b/module/chart/test/lib/zen.class.php index 52bdbb3ad3..c14ed16153 100644 --- a/module/chart/test/lib/zen.class.php +++ b/module/chart/test/lib/zen.class.php @@ -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; + } } diff --git a/module/chart/test/zen/getcharttofilter.php b/module/chart/test/zen/getcharttofilter.php new file mode 100755 index 0000000000..dfc2db5561 --- /dev/null +++ b/module/chart/test/zen/getcharttofilter.php @@ -0,0 +1,35 @@ +#!/usr/bin/env php +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'); \ No newline at end of file diff --git a/module/chart/test/zen/yaml/getcharttofilter/chart.yaml b/module/chart/test/zen/yaml/getcharttofilter/chart.yaml new file mode 100644 index 0000000000..b976103810 --- /dev/null +++ b/module/chart/test/zen/yaml/getcharttofilter/chart.yaml @@ -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: ""