From 22ffd1ec0e73f6eea60cd6fb23ec34618e80e23b Mon Sep 17 00:00:00 2001 From: liugang Date: Tue, 9 Sep 2025 08:18:54 +0800 Subject: [PATCH] + [misc] Add unit tests for pivotModel::execDrillSQL() 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 --- .../pivot/test/lib/pivot.unittest.class.php | 17 +++++++++ module/pivot/test/model/execdrillsql.php | 36 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100755 module/pivot/test/model/execdrillsql.php diff --git a/module/pivot/test/lib/pivot.unittest.class.php b/module/pivot/test/lib/pivot.unittest.class.php index 715cf9a590..2c608f9647 100644 --- a/module/pivot/test/lib/pivot.unittest.class.php +++ b/module/pivot/test/lib/pivot.unittest.class.php @@ -1127,4 +1127,21 @@ class pivotTest return $result; } + + /** + * Test execDrillSQL method. + * + * @param string $object + * @param string $drillSQL + * @param int $limit + * @access public + * @return array + */ + public function execDrillSQLTest($object, $drillSQL, $limit = 10) + { + $result = $this->objectModel->execDrillSQL($object, $drillSQL, $limit); + if(dao::isError()) return dao::getError(); + + return $result; + } } \ No newline at end of file diff --git a/module/pivot/test/model/execdrillsql.php b/module/pivot/test/model/execdrillsql.php new file mode 100755 index 0000000000..e9cf644b77 --- /dev/null +++ b/module/pivot/test/model/execdrillsql.php @@ -0,0 +1,36 @@ +#!/usr/bin/env php +execDrillSQLTest('user', 'SELECT 1 as test', 10)) && p('status') && e('success'); // 步骤1:正常情况 +r($pivotTest->execDrillSQLTest('user', 'SELECT * FROM zt_user WHERE id > 0 LIMIT 2', 5)) && p('status') && e('success'); // 步骤2:限制数量 +r($pivotTest->execDrillSQLTest('user', '', 10)) && p('status') && e('fail'); // 步骤3:空SQL +r($pivotTest->execDrillSQLTest('user', 'INVALID SQL SYNTAX', 10)) && p('status') && e('fail'); // 步骤4:无效SQL +r($pivotTest->execDrillSQLTest('user', 'SELECT 2 as test', 0)) && p('status') && e('success'); // 步骤5:边界值limit为0 \ No newline at end of file