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