From cfcaad17e326e069067b00beafba5a94015d2c85 Mon Sep 17 00:00:00 2001 From: liugang Date: Tue, 9 Sep 2025 19:22:23 +0800 Subject: [PATCH] + [misc] Add unit tests for screenModel::buildDataset() 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 --- .../screen/test/lib/screen.unittest.class.php | 17 +++++++++++ module/screen/test/model/builddataset.php | 29 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 module/screen/test/model/builddataset.php diff --git a/module/screen/test/lib/screen.unittest.class.php b/module/screen/test/lib/screen.unittest.class.php index 8fbc2e7140..d7fd1b19f8 100755 --- a/module/screen/test/lib/screen.unittest.class.php +++ b/module/screen/test/lib/screen.unittest.class.php @@ -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; + } + } diff --git a/module/screen/test/model/builddataset.php b/module/screen/test/model/builddataset.php new file mode 100755 index 0000000000..1a4be62e66 --- /dev/null +++ b/module/screen/test/model/builddataset.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +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'); \ No newline at end of file