* [misc] Enhance unit tests for pivotModel::checkIFChartInUse() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2417,6 +2417,23 @@ class pivotTest
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test checkIFChartInUse method.
|
||||
*
|
||||
* @param int $chartID
|
||||
* @param string $type
|
||||
* @param array $screens
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function checkIFChartInUseTest(int $chartID, string $type = 'chart', array $screens = array()): bool
|
||||
{
|
||||
$result = $this->objectModel->checkIFChartInUse($chartID, $type, $screens);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getFilterOptionUrl method.
|
||||
*
|
||||
@@ -2434,7 +2451,7 @@ class pivotTest
|
||||
|
||||
// 直接实现 getFilterOptionUrl 方法的逻辑,避免复杂的依赖问题
|
||||
// 根据 pivot/zen.php 第497-526行的实现
|
||||
|
||||
|
||||
$field = $filter['field'];
|
||||
$from = isset($filter['from']) ? $filter['from'] : 'result';
|
||||
$value = isset($filter['default']) ? $filter['default'] : '';
|
||||
@@ -2444,7 +2461,7 @@ class pivotTest
|
||||
$url = 'http://example.com/pivot/ajaxGetSysOptions';
|
||||
$data = array();
|
||||
$data['values'] = $values;
|
||||
|
||||
|
||||
if($from == 'query')
|
||||
{
|
||||
$data['type'] = $filter['typeOption'];
|
||||
|
||||
@@ -3,23 +3,68 @@
|
||||
|
||||
/**
|
||||
|
||||
title=测试 pivotModel->checkIfChartInUse().
|
||||
title=测试 pivotModel::checkIFChartInUse();
|
||||
timeout=0
|
||||
cid=1
|
||||
cid=0
|
||||
|
||||
- id为1000的透视表被大屏使用了 @1
|
||||
- id为1003的透视表未被大屏使用 @1
|
||||
- 执行pivotTest模块的checkIFChartInUseTest方法,参数是1002, 'pivot', $screenList @1
|
||||
- 执行pivotTest模块的checkIFChartInUseTest方法,参数是2001, 'chart', $screenList @1
|
||||
- 执行pivotTest模块的checkIFChartInUseTest方法,参数是9999, 'pivot', $screenList @0
|
||||
- 执行pivotTest模块的checkIFChartInUseTest方法,参数是1002, 'pivot', $screenList @1
|
||||
- 执行pivotTest模块的checkIFChartInUseTest方法,参数是0, 'chart', $screenList @0
|
||||
- 执行pivotTest模块的checkIFChartInUseTest方法,参数是5000, 'pivot', $screenList @0
|
||||
- 执行pivotTest模块的checkIFChartInUseTest方法,参数是1002, 'pivot', array @1
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/pivot.unittest.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$pivotTest = new pivotTest();
|
||||
|
||||
$pivotIDList = array(1002, 1003);
|
||||
$screenList = array();
|
||||
|
||||
$screenList = $tester->dao->select('*')->from(TABLE_SCREEN)->where('deleted')->eq(0)->andWhere('status')->eq('published')->fetchAll('', false);
|
||||
$screen1 = new stdClass();
|
||||
$screen1->id = 1;
|
||||
$screen1->scheme = '';
|
||||
$screen1->status = 'published';
|
||||
$screen1->deleted = 0;
|
||||
$screenList[] = $screen1;
|
||||
|
||||
r($pivotTest->checkIfChartInUse($pivotIDList[0], 'pivot', $screenList)) && p('') && e(1); //id为1000的透视表被大屏使用了
|
||||
r(!$pivotTest->checkIfChartInUse($pivotIDList[1], 'pivot', $screenList)) && p('') && e(1); //id为1003的透视表未被大屏使用
|
||||
$screen2 = new stdClass();
|
||||
$screen2->id = 2;
|
||||
$screen2->scheme = '{"componentList":[]}';
|
||||
$screen2->status = 'published';
|
||||
$screen2->deleted = 0;
|
||||
$screenList[] = $screen2;
|
||||
|
||||
$screen3 = new stdClass();
|
||||
$screen3->id = 3;
|
||||
$screen3->scheme = '{"componentList":[{"chartConfig":{"sourceID":1002,"package":"Tables"}}]}';
|
||||
$screen3->status = 'published';
|
||||
$screen3->deleted = 0;
|
||||
$screenList[] = $screen3;
|
||||
|
||||
$screen4 = new stdClass();
|
||||
$screen4->id = 4;
|
||||
$screen4->scheme = '{"componentList":[{"chartConfig":{"sourceID":2001,"package":"Charts"}}]}';
|
||||
$screen4->status = 'published';
|
||||
$screen4->deleted = 0;
|
||||
$screenList[] = $screen4;
|
||||
|
||||
$screen5 = new stdClass();
|
||||
$screen5->id = 5;
|
||||
$screen5->scheme = '{"componentList":[{"isGroup":true,"groupList":[{"chartConfig":{"sourceID":1002,"package":"Tables"}},{"chartConfig":{"sourceID":2002,"package":"Charts"}}]}]}';
|
||||
$screen5->status = 'published';
|
||||
$screen5->deleted = 0;
|
||||
$screenList[] = $screen5;
|
||||
|
||||
r($pivotTest->checkIFChartInUseTest(1002, 'pivot', $screenList)) && p('') && e('1');
|
||||
r($pivotTest->checkIFChartInUseTest(2001, 'chart', $screenList)) && p('') && e('1');
|
||||
r($pivotTest->checkIFChartInUseTest(9999, 'pivot', $screenList)) && p('') && e('0');
|
||||
r($pivotTest->checkIFChartInUseTest(1002, 'pivot', $screenList)) && p('') && e('1');
|
||||
r($pivotTest->checkIFChartInUseTest(0, 'chart', $screenList)) && p('') && e('0');
|
||||
r($pivotTest->checkIFChartInUseTest(5000, 'pivot', $screenList)) && p('') && e('0');
|
||||
r($pivotTest->checkIFChartInUseTest(1002, 'pivot', array())) && p('') && e('1');
|
||||
@@ -0,0 +1,117 @@
|
||||
---
|
||||
title: screen表测试数据
|
||||
desc: 用于测试checkIFChartInUse方法
|
||||
author: Claude
|
||||
version: 1.0
|
||||
|
||||
fields:
|
||||
- field: id
|
||||
note: 大屏ID
|
||||
range: 1-10
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: dimension
|
||||
note: 维度ID
|
||||
range: 1
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: name
|
||||
note: 大屏名称
|
||||
range: '["测试大屏1", "测试大屏2", "透视表大屏", "图表大屏", "空配置大屏"]'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: desc
|
||||
note: 大屏描述
|
||||
range: '["用于测试的大屏1", "用于测试的大屏2", "包含透视表的大屏", "包含图表的大屏", "配置为空的大屏"]'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: acl
|
||||
note: 访问权限
|
||||
range: open
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: whitelist
|
||||
note: 白名单
|
||||
range: '""'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: cover
|
||||
note: 封面
|
||||
range: '""'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: scheme
|
||||
note: 配置方案JSON
|
||||
range: |-
|
||||
["",
|
||||
"{\"componentList\":[]}",
|
||||
"{\"componentList\":[{\"chartConfig\":{\"sourceID\":1002,\"package\":\"Tables\"}}]}",
|
||||
"{\"componentList\":[{\"chartConfig\":{\"sourceID\":2001,\"package\":\"Charts\"}}]}",
|
||||
"{\"componentList\":[{\"isGroup\":true,\"groupList\":[{\"chartConfig\":{\"sourceID\":1002,\"package\":\"Tables\"}},{\"chartConfig\":{\"sourceID\":2002,\"package\":\"Charts\"}}]}]}"]
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: status
|
||||
note: 状态
|
||||
range: published
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: builtin
|
||||
note: 是否内置
|
||||
range: '0'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: createdBy
|
||||
note: 创建者
|
||||
range: admin
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: createdDate
|
||||
note: 创建时间
|
||||
range: '2024-01-01 12:00:00'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: editedBy
|
||||
note: 编辑者
|
||||
range: admin
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: editedDate
|
||||
note: 编辑时间
|
||||
range: '2024-01-01 13:00:00'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
- field: deleted
|
||||
note: 是否删除
|
||||
range: '0'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
format: ""
|
||||
Reference in New Issue
Block a user