znt/module/pivot/test/model/execdrillsql.php

36 lines
1.4 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
/**
title=测试 pivotModel::execDrillSQL();
timeout=0
cid=17362
- 步骤1正常情况属性status @success
- 步骤2限制数量属性status @success
- 步骤3空SQL属性status @fail
- 步骤4无效SQL属性status @fail
- 步骤5边界值limit为0属性status @success
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 模拟最基本的数据不使用zenData避免输出干扰
// 测试execDrillSQL方法不需要实际的数据库数据它主要测试SQL执行逻辑
// 3. 用户登录(选择合适角色)
su('admin');
// 4. 创建测试实例(变量名与模块名一致)
$pivotTest = new pivotModelTest();
// 5. 🔴 强制要求必须包含至少5个测试步骤
r($pivotTest->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