+ [misc] Add unit tests for screenModel::buildDataset() method

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-15 15:06:22 +08:00
co-authored by Claude
parent 645e42ad6b
commit cfcaad17e3
2 changed files with 46 additions and 0 deletions
@@ -1228,4 +1228,21 @@ class screenTest
return $result;
}
/**
* Test buildDataset method.
*
* @param int $chartID
* @param string $driver
* @param string $sql
* @access public
* @return mixed
*/
public function buildDatasetTest($chartID, $driver, $sql = '')
{
$result = $this->objectModel->buildDataset($chartID, $driver, $sql);
if(dao::isError()) return dao::getError();
return $result;
}
}
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php
/**
title=测试 screenModel::buildDataset();
timeout=0
cid=0
- 执行screenTest模块的buildDatasetTest方法,参数是20002, 'mysql', '' 第0条的count属性 @0
- 执行screenTest模块的buildDatasetTest方法,参数是20004, 'mysql', '' 第0条的count属性 @0
- 执行screenTest模块的buildDatasetTest方法,参数是20007, 'mysql', '' 第0条的count属性 @0
- 执行screenTest模块的buildDatasetTest方法,参数是10018, 'mysql', 'SELECT COUNT 第0条的count属性 @5
- 执行screenTest模块的buildDatasetTest方法,参数是999, 'mysql', 'SELECT 1 as test' 第0条的test属性 @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/screen.unittest.class.php';
su('admin');
$screenTest = new screenTest();
r($screenTest->buildDatasetTest(20002, 'mysql', '')) && p('0:count') && e('0');
r($screenTest->buildDatasetTest(20004, 'mysql', '')) && p('0:count') && e('0');
r($screenTest->buildDatasetTest(20007, 'mysql', '')) && p('0:count') && e('0');
r($screenTest->buildDatasetTest(10018, 'mysql', 'SELECT COUNT(*) as count FROM zt_user')) && p('0:count') && e('5');
r($screenTest->buildDatasetTest(999, 'mysql', 'SELECT 1 as test')) && p('0:test') && e('1');