Start testcase for SQL parser.
This commit is contained in:
@@ -43,7 +43,9 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
* Include data for the SQL Parser
|
||||
*/
|
||||
require_once './libraries/sqlparser.data.php';
|
||||
require_once './libraries/mysql_charsets.lib.php';
|
||||
if (!defined('TESTSUITE')) {
|
||||
require_once './libraries/mysql_charsets.lib.php';
|
||||
}
|
||||
if (!isset($mysql_charsets)) {
|
||||
$mysql_charsets = array();
|
||||
$mysql_charsets_count = 0;
|
||||
|
64
test/PMA_SQL_parser_test.php
Normal file
64
test/PMA_SQL_parser_test.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* tests for correctness of SQL parser
|
||||
*
|
||||
* @package phpMyAdmin-test
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests core.
|
||||
*/
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
|
||||
define('PHPMYADMIN', 1);
|
||||
define('TESTSUITE', 1);
|
||||
$GLOBALS['charset'] = 'utf-8';
|
||||
|
||||
/**
|
||||
* Include to test.
|
||||
*/
|
||||
require_once './libraries/sqlparser.lib.php';
|
||||
|
||||
/**
|
||||
* Test for SQL parser
|
||||
*
|
||||
* @package phpMyAdmin-test
|
||||
*/
|
||||
class PMA_SQL_parser_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private function assertParser($sql, $expected)
|
||||
{
|
||||
$parsed_sql = PMA_SQP_parse($sql);
|
||||
$this->assertEquals($parsed_sql, $expected);
|
||||
}
|
||||
|
||||
public function testParse_1()
|
||||
{
|
||||
$this->assertParser('SELECT 1;', array (
|
||||
'raw' => 'SELECT 1;',
|
||||
0 =>
|
||||
array (
|
||||
'type' => 'alpha_reservedWord',
|
||||
'data' => 'SELECT',
|
||||
'pos' => 6,
|
||||
'forbidden' => true,
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'type' => 'digit_integer',
|
||||
'data' => '1',
|
||||
'pos' => 8,
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'type' => 'punct_queryend',
|
||||
'data' => ';',
|
||||
'pos' => 0,
|
||||
),
|
||||
'len' => 3,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user