znt/module/metric/test/model/parsesqlfunction.php

39 lines
1.8 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=测试 metricModel::parseSqlFunction();
timeout=0
cid=17146
- 步骤1标准CREATE FUNCTION语句 @calculate_score
- 步骤2小写CREATE FUNCTION语句 @user_count
- 步骤3复杂函数名测试 @complex_func_123
- 步骤4不完整语句测试 @0
- 步骤5空字符串测试 @0
- 步骤6无效SQL语句测试 @0
- 步骤7多行语句测试 @multiline_func
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/calc.unittest.class.php';
$metricTest = new metricTest();
// 测试数据准备
$standardFunc = 'CREATE FUNCTION `calculate_score`(';
$lowercaseFunc = 'create function `user_count`(';
$complexFunc = 'CREATE FUNCTION `complex_func_123`(';
$incompleteFunc = 'create function `incomplete_func`';
$emptyString = '';
$invalidSql = 'SELECT * FROM users';
$multilineFunc = "CREATE FUNCTION `multiline_func`(\n param1 INT,\n param2 VARCHAR(50)\n)(";
r($metricTest->parseSqlFunction($standardFunc)) && p() && e('calculate_score'); // 步骤1标准CREATE FUNCTION语句
r($metricTest->parseSqlFunction($lowercaseFunc)) && p() && e('user_count'); // 步骤2小写CREATE FUNCTION语句
r($metricTest->parseSqlFunction($complexFunc)) && p() && e('complex_func_123'); // 步骤3复杂函数名测试
r($metricTest->parseSqlFunction($incompleteFunc)) && p() && e('0'); // 步骤4不完整语句测试
r($metricTest->parseSqlFunction($emptyString)) && p() && e('0'); // 步骤5空字符串测试
r($metricTest->parseSqlFunction($invalidSql)) && p() && e('0'); // 步骤6无效SQL语句测试
r($metricTest->parseSqlFunction($multilineFunc)) && p() && e('multiline_func'); // 步骤7多行语句测试