Add testcase for failed parsing.

This commit is contained in:
Michal Čihař
2010-08-30 16:00:33 +02:00
parent 4afbb59588
commit e781f7f9b9

View File

@@ -15,6 +15,10 @@ define('PHPMYADMIN', 1);
define('TESTSUITE', 1);
$GLOBALS['charset'] = 'utf-8';
function __($s) {
return $s;
}
/**
* Include to test.
*/
@@ -27,9 +31,10 @@ require_once './libraries/sqlparser.lib.php';
*/
class PMA_SQL_parser_test extends PHPUnit_Framework_TestCase
{
private function assertParser($sql, $expected)
private function assertParser($sql, $expected, $error = '')
{
$parsed_sql = PMA_SQP_parse($sql);
$this->assertEquals(PMA_SQP_getErrorString(), $error);
$this->assertEquals($parsed_sql, $expected);
}
@@ -140,5 +145,37 @@ class PMA_SQL_parser_test extends PHPUnit_Framework_TestCase
'len' => 5,
));
}
public function testParse_4()
{
$this->assertParser('SELECT * from `aaa;', array (
'raw' => 'SELECT * from `aaa;',
0 =>
array (
'type' => 'alpha',
'data' => 'SELECT',
'pos' => 6,
),
1 =>
array (
'type' => 'punct',
'data' => '*',
'pos' => 0,
),
2 =>
array (
'type' => 'alpha',
'data' => 'from',
'pos' => 13,
),
),
'<p>There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem</p>
<pre>
ERROR: Unclosed quote @ 14
STR: `
SQL: SELECT * from `aaa;
</pre>
');
}
}
?>