From 2e6a80c47d7b02447faf96a22153862ee5b480ff Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 25 Jun 2018 02:16:28 +0200 Subject: [PATCH] Fix tests for regression #14422 Signed-off-by: William Desportes --- libraries/classes/Dbi/DbiDummy.php | 158 +++++++++++++++++++++++++++++ test/classes/TableTest.php | 36 +++---- 2 files changed, 176 insertions(+), 18 deletions(-) diff --git a/libraries/classes/Dbi/DbiDummy.php b/libraries/classes/Dbi/DbiDummy.php index 3741e1f1e5..b0d01e17f8 100644 --- a/libraries/classes/Dbi/DbiDummy.php +++ b/libraries/classes/Dbi/DbiDummy.php @@ -1267,6 +1267,164 @@ class DbiDummy implements DbiExtension 'query' => "SHOW TABLE STATUS FROM `db` WHERE `Name` LIKE 'table%'", 'result' => [], ], + [ + 'query' => "SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`," + . " `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`," + . " `ENGINE` AS `Type`, `VERSION` AS `Version`, `ROW_FORMAT` AS `Row_format`," + . " `TABLE_ROWS` AS `Rows`, `AVG_ROW_LENGTH` AS `Avg_row_length`," + . " `DATA_LENGTH` AS `Data_length`, `MAX_DATA_LENGTH` AS `Max_data_length`," + . " `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`," + . " `AUTO_INCREMENT` AS `Auto_increment`, `CREATE_TIME` AS `Create_time`," + . " `UPDATE_TIME` AS `Update_time`, `CHECK_TIME` AS `Check_time`," + . " `TABLE_COLLATION` AS `Collation`, `CHECKSUM` AS `Checksum`," + . " `CREATE_OPTIONS` AS `Create_options`, `TABLE_COMMENT` AS `Comment`" + . " FROM `information_schema`.`TABLES` t WHERE `TABLE_SCHEMA` IN ('table1')" + . " AND t.`TABLE_NAME` = 'pma_test' ORDER BY Name ASC", + 'columns' => [ + 'TABLE_CATALOG', + 'TABLE_SCHEMA', + 'TABLE_NAME', + 'TABLE_TYPE', + 'ENGINE', + 'VERSION', + 'ROW_FORMAT', + 'TABLE_ROWS', + 'AVG_ROW_LENGTH', + 'DATA_LENGTH', + 'MAX_DATA_LENGTH', + 'INDEX_LENGTH', + 'DATA_FREE', + 'AUTO_INCREMENT', + 'CREATE_TIME', + 'UPDATE_TIME', + 'CHECK_TIME', + 'TABLE_COLLATION', + 'CHECKSUM', + 'CREATE_OPTIONS', + 'TABLE_COMMENT', + 'Db', + 'Name', + 'TABLE_TYPE', + 'Engine', + 'Type', + 'Version', + 'Row_format', + 'Rows', + 'Avg_row_length', + 'Data_length', + 'Max_data_length', + 'Index_length', + 'Data_free', + 'Auto_increment', + 'Create_time', + 'Update_time', + 'Check_time', + 'Collation', + 'Checksum', + 'Create_options', + 'Comment', + ], + 'result' => [ + [ + 'ref', + 'pma_test', + 'table1', + 'BASE TABLE', + 'DBIdummy', + '11', + 'Redundant', + '123456', + '42', + '21708991', + '281474976710655',// MyISAM + '2048',// MyISAM + '2547', + '5', + '2014-06-24 17:30:00', + '2018-06-25 18:35:12', + '2015-04-24 19:30:59', + 'utf8mb4_general_ci', + '3844432963', + 'row_format=REDUNDANT', + 'Test comment for "table1" in \'pma_test\'', + 'table1', + 'DBIdummy', + '11', + 'Redundant', + '123456', + '42', + '21708991', + '281474976710655',// MyISAM + '2048',// MyISAM + '2547', + '5', + '2014-06-24 17:30:00', + '2018-06-25 18:35:12', + '2015-04-24 19:30:59', + 'utf8mb4_general_ci', + '3844432963', + 'row_format=REDUNDANT', + 'Test comment for "table1" in \'pma_test\'', + ] + ], + ], + [ + 'query' => "SHOW TABLE STATUS FROM `table1` WHERE `Name` LIKE 'pma\_test%'", + 'columns' => [ + 'Name', + 'TABLE_TYPE', + 'Engine', + 'Type', + 'Version', + 'Row_format', + 'Rows', + 'Avg_row_length', + 'Data_length', + 'Max_data_length', + 'Index_length', + 'Data_free', + 'Auto_increment', + 'Create_time', + 'Update_time', + 'Check_time', + 'Collation', + 'Checksum', + 'Create_options', + 'Comment', + ], + 'result' => [ + [ + 'table1', + 'DBIdummy', + '11', + 'Redundant', + '123456', + '42', + '21708991', + '281474976710655',// MyISAM + '2048',// MyISAM + '2547', + '5', + '2014-06-24 17:30:00', + '2018-06-25 18:35:12', + '2015-04-24 19:30:59', + 'utf8mb4_general_ci', + '3844432963', + 'row_format=REDUNDANT', + 'Test comment for "table1" in \'pma_test\'', + ] + ], + ], + [ + 'query' => "SELECT *, CAST(BIN_NAME AS CHAR CHARACTER SET utf8) AS SCHEMA_NAME FROM (SELECT BINARY s.SCHEMA_NAME AS BIN_NAME, s.DEFAULT_COLLATION_NAME FROM `information_schema`.SCHEMATA s WHERE `SCHEMA_NAME` LIKE 'pma_test' GROUP BY BINARY s.SCHEMA_NAME, s.DEFAULT_COLLATION_NAME ORDER BY BINARY `SCHEMA_NAME` ASC) a", + 'result' => [ + [ + 'BIN_NAME' => 'pma_test', + 'DEFAULT_COLLATION_NAME' => 'utf8mb4_general_ci', + 'SCHEMA_NAME' => 'pma_test', + ] + ], + ], [ 'query' => "SELECT @@have_partitioning;", 'result' => [], diff --git a/test/classes/TableTest.php b/test/classes/TableTest.php index a7a2db9465..255b2fb5bb 100644 --- a/test/classes/TableTest.php +++ b/test/classes/TableTest.php @@ -1341,11 +1341,11 @@ class TableTest extends PmaTestCase { $target_table = 'table1'; $target_db = 'pma_test'; - $tbl_object = new Table($target_db, $target_table); - $tbl_object->getStatusInfo(null, true); $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $expect = ''; + $tbl_object = new Table($target_db, $target_table, $dbi); + $tbl_object->getStatusInfo(null, true); + $expect = 'DBIDUMMY'; $tbl_storage_engine = $dbi->getTable( $target_db, $target_table @@ -1365,11 +1365,11 @@ class TableTest extends PmaTestCase { $target_table = 'table1'; $target_db = 'pma_test'; - $tbl_object = new Table($target_db, $target_table); - $tbl_object->getStatusInfo(null, true); $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $expect = ''; + $tbl_object = new Table($target_db, $target_table, $dbi); + $tbl_object->getStatusInfo(null, true); + $expect = 'Test comment for "table1" in \'pma_test\''; $show_comment = $dbi->getTable( $target_db, $target_table @@ -1389,11 +1389,11 @@ class TableTest extends PmaTestCase { $target_table = 'table1'; $target_db = 'pma_test'; - $tbl_object = new Table($target_db, $target_table); - $tbl_object->getStatusInfo(null, true); $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $expect = ''; + $tbl_object = new Table($target_db, $target_table, $dbi); + $tbl_object->getStatusInfo(null, true); + $expect = 'utf8mb4_general_ci'; $tbl_collation = $dbi->getTable( $target_db, $target_table @@ -1413,11 +1413,11 @@ class TableTest extends PmaTestCase { $target_table = 'table1'; $target_db = 'pma_test'; - $tbl_object = new Table($target_db, $target_table); - $tbl_object->getStatusInfo(null, true); $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $expect = ''; + $tbl_object = new Table($target_db, $target_table, $dbi); + $tbl_object->getStatusInfo(null, true); + $expect = 'Redundant'; $row_format = $dbi->getTable( $target_db, $target_table @@ -1437,11 +1437,11 @@ class TableTest extends PmaTestCase { $target_table = 'table1'; $target_db = 'pma_test'; - $tbl_object = new Table($target_db, $target_table); - $tbl_object->getStatusInfo(null, true); $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $expect = ''; + $tbl_object = new Table($target_db, $target_table, $dbi); + $tbl_object->getStatusInfo(null, true); + $expect = '5'; $auto_increment = $dbi->getTable( $target_db, $target_table @@ -1461,11 +1461,11 @@ class TableTest extends PmaTestCase { $target_table = 'table1'; $target_db = 'pma_test'; - $tbl_object = new Table($target_db, $target_table); - $tbl_object->getStatusInfo(null, true); $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $expect = ['pack_keys' => 'DEFAULT']; + $tbl_object = new Table($target_db, $target_table, $dbi); + $tbl_object->getStatusInfo(null, true); + $expect = ['pack_keys' => 'DEFAULT', 'row_format' => 'REDUNDANT']; $create_options = $dbi->getTable( $target_db, $target_table