From 95d30e736a44a8fc3c478684f514da9c0450065b Mon Sep 17 00:00:00 2001 From: liugang Date: Wed, 24 Sep 2025 15:43:59 +0800 Subject: [PATCH] * [misc] Enhance unit tests for pivotModel::getConnectSQL() 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 --- module/pivot/test/model/getconnectsql.php | 43 ++++++++++------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/module/pivot/test/model/getconnectsql.php b/module/pivot/test/model/getconnectsql.php index b11133e10c..dd218df447 100755 --- a/module/pivot/test/model/getconnectsql.php +++ b/module/pivot/test/model/getconnectsql.php @@ -7,7 +7,16 @@ title=测试 pivotModel::getConnectSQL(); timeout=0 cid=0 -- 步骤1:空数组过滤条件输入测试 @0 +- 步骤1:空数组输入测试 @0 +- 步骤2:包含from键的过滤条件测试 @0 +- 步骤3:单个等号操作符过滤条件测试 @ where tt.`status` = 'active' +- 步骤4:多个过滤条件AND组合测试 @ where tt.`name` = 'test' and tt.`score` > 100 +- 步骤5:各种SQL操作符组合测试 @ where tt.`id` != 0 and tt.`type` LIKE '%bug%' and tt.`priority` IN ('1','2','3') + +- 步骤6:特殊字符和转义测试 @ where tt.`description` LIKE '%can\'t%' +- 步骤7:数值型条件组合测试 @ where tt.`count` >= 50 and tt.`level` < 10 +- 步骤8:小写操作符测试 @ where tt.`status` like '%test%' +- 步骤9:空字符串值过滤测试 @ where tt.`title` != '' */ @@ -18,26 +27,12 @@ su('admin'); $pivotTest = new pivotTest(); -r($pivotTest->getConnectSQLTest(array())) && p() && e('0'); // 步骤1:空数组过滤条件输入测试 -r($pivotTest->getConnectSQLTest(array( - 0 => array('from' => 'query', 'field' => 'name') -))) && p() && e('0'); // 步骤2:包含from键的过滤条件测试 -r($pivotTest->getConnectSQLTest(array( - 'status' => array('field' => 'status', 'operator' => '=', 'value' => "'active'") -))) && p() && e(' where tt.`status` = \'active\''); // 步骤3:单个等号操作符过滤条件测试 -r($pivotTest->getConnectSQLTest(array( - 'name' => array('field' => 'name', 'operator' => '=', 'value' => "'test'"), - 'score' => array('field' => 'score', 'operator' => '>', 'value' => '100') -))) && p() && e(' where tt.`name` = \'test\' and tt.`score` > 100'); // 步骤4:多个过滤条件组合测试 -r($pivotTest->getConnectSQLTest(array( - 'id' => array('field' => 'id', 'operator' => '!=', 'value' => '0'), - 'type' => array('field' => 'type', 'operator' => 'LIKE', 'value' => "'%bug%'"), - 'priority' => array('field' => 'priority', 'operator' => 'IN', 'value' => "('1','2','3')") -))) && p() && e(' where tt.`id` != 0 and tt.`type` LIKE \'%bug%\' and tt.`priority` IN (\'1\',\'2\',\'3\')'); // 步骤5:各种操作符组合测试 -r($pivotTest->getConnectSQLTest(array( - 'description' => array('field' => 'description', 'operator' => 'LIKE', 'value' => "'%can\\'t%'") -))) && p() && e(' where tt.`description` LIKE \'%can\\\'t%\''); // 步骤6:特殊字符和转义测试 -r($pivotTest->getConnectSQLTest(array( - 'count' => array('field' => 'count', 'operator' => '>=', 'value' => '50'), - 'level' => array('field' => 'level', 'operator' => '<', 'value' => '10') -))) && p() && e(' where tt.`count` >= 50 and tt.`level` < 10'); // 步骤7:数值类型过滤条件测试 // 步骤5:各种操作符的过滤条件测试 \ No newline at end of file +r($pivotTest->getConnectSQLTest(array())) && p() && e('0'); // 步骤1:空数组输入测试 +r($pivotTest->getConnectSQLTest(array(0 => array('from' => 'query', 'field' => 'name')))) && p() && e('0'); // 步骤2:包含from键的过滤条件测试 +r($pivotTest->getConnectSQLTest(array('status' => array('field' => 'status', 'operator' => '=', 'value' => "'active'")))) && p() && e(" where tt.`status` = 'active'"); // 步骤3:单个等号操作符过滤条件测试 +r($pivotTest->getConnectSQLTest(array('name' => array('field' => 'name', 'operator' => '=', 'value' => "'test'"), 'score' => array('field' => 'score', 'operator' => '>', 'value' => '100')))) && p() && e(" where tt.`name` = 'test' and tt.`score` > 100"); // 步骤4:多个过滤条件AND组合测试 +r($pivotTest->getConnectSQLTest(array('id' => array('field' => 'id', 'operator' => '!=', 'value' => '0'), 'type' => array('field' => 'type', 'operator' => 'LIKE', 'value' => "'%bug%'"), 'priority' => array('field' => 'priority', 'operator' => 'IN', 'value' => "('1','2','3')")))) && p() && e(" where tt.`id` != 0 and tt.`type` LIKE '%bug%' and tt.`priority` IN ('1','2','3')"); // 步骤5:各种SQL操作符组合测试 +r($pivotTest->getConnectSQLTest(array('description' => array('field' => 'description', 'operator' => 'LIKE', 'value' => "'%can\\'t%'")))) && p() && e(" where tt.`description` LIKE '%can\'t%'"); // 步骤6:特殊字符和转义测试 +r($pivotTest->getConnectSQLTest(array('count' => array('field' => 'count', 'operator' => '>=', 'value' => '50'), 'level' => array('field' => 'level', 'operator' => '<', 'value' => '10')))) && p() && e(" where tt.`count` >= 50 and tt.`level` < 10"); // 步骤7:数值型条件组合测试 +r($pivotTest->getConnectSQLTest(array('status' => array('field' => 'status', 'operator' => 'like', 'value' => "'%test%'")))) && p() && e(" where tt.`status` like '%test%'"); // 步骤8:小写操作符测试 +r($pivotTest->getConnectSQLTest(array('title' => array('field' => 'title', 'operator' => '!=', 'value' => "''")))) && p() && e(" where tt.`title` != ''"); // 步骤9:空字符串值过滤测试 \ No newline at end of file