From eeafcad986917b581292a1c7ac0c27cf98f67787 Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Tue, 7 Jul 2015 03:21:38 +0300 Subject: Using the new parser to simulate queries. Updated sql-parser library to udan11/sql-parser@e58d230. Signed-off-by: Dan Ungureanu --- test/libraries/PMA_import_test.php | 41 ++++++++------------------------------ 1 file changed, 8 insertions(+), 33 deletions(-) (limited to 'test') diff --git a/test/libraries/PMA_import_test.php b/test/libraries/PMA_import_test.php index d47e11caa6..96472e08e2 100644 --- a/test/libraries/PMA_import_test.php +++ b/test/libraries/PMA_import_test.php @@ -328,32 +328,6 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase ); } - /** - * Test for PMA_getTableReferences - * - * @return void - */ - function testPMAGetTableReferences() - { - $sql_query = 'UPDATE `table_1` AS t1, `table_2` t2, `table_3` AS t3 ' - . 'SET `table_1`.`id` = `table_2`.`id` ' - . 'WHERE 1'; - - $parsed_sql = PMA_SQP_parse($sql_query); - $analyzed_sql = PMA_SQP_analyze($parsed_sql); - $analyzed_sql_results = array( - 'parsed_sql' => $parsed_sql, - 'analyzed_sql' => $analyzed_sql - ); - - $table_references = PMA_getTableReferences($analyzed_sql_results); - - $this->assertEquals( - ' `table_1` AS t1 , `table_2` t2 , `table_3` AS t3', - $table_references - ); - } - /** * Test for PMA_getMatchedRows. * @@ -370,10 +344,11 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase $update_query = 'UPDATE `table_1` ' . 'SET `id` = 20 ' . 'WHERE `id` > 10'; - $simulated_update_query = 'SELECT `id` FROM `table_1` WHERE `id` > 10 '; + $simulated_update_query = 'SELECT `id` FROM `table_1` WHERE `id` > 10 AND (`id` <> 20)'; + $delete_query = 'DELETE FROM `table_1` ' . 'WHERE `id` > 10'; - $simulated_delete_query = 'SELECT * FROM `table_1` WHERE `id` > 10 '; + $simulated_delete_query = 'SELECT * FROM `table_1` WHERE `id` > 10'; $dbi->expects($this->any()) ->method('numRows') @@ -411,11 +386,11 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase */ function simulatedQueryTest($sql_query, $simulated_query) { - $parsed_sql = PMA_SQP_parse($sql_query); - $analyzed_sql = PMA_SQP_analyze($parsed_sql); + $parser = new SqlParser\Parser($sql_query); $analyzed_sql_results = array( - 'parsed_sql' => $parsed_sql, - 'analyzed_sql' => $analyzed_sql + 'query' => $sql_query, + 'parser' => $parser, + 'statement' => $parser->statements[0], ); $simulated_data = PMA_getMatchedRows($analyzed_sql_results); @@ -430,7 +405,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase $this->assertEquals( array( 'sql_query' => PMA_Util::formatSql( - $analyzed_sql_results['parsed_sql']['raw'] + $analyzed_sql_results['query'] ), 'matched_rows' => 2, 'matched_rows_url' => $matched_rows_url -- cgit v1.2.3