diff options
-rw-r--r-- | test/classes/DatabaseInterfaceTest.php | 110 | ||||
-rw-r--r-- | test/classes/Stubs/DbiDummy.php | 156 |
2 files changed, 266 insertions, 0 deletions
diff --git a/test/classes/DatabaseInterfaceTest.php b/test/classes/DatabaseInterfaceTest.php index a0a675900d..376623bef7 100644 --- a/test/classes/DatabaseInterfaceTest.php +++ b/test/classes/DatabaseInterfaceTest.php @@ -367,4 +367,114 @@ class DatabaseInterfaceTest extends AbstractTestCase $this->assertAllQueriesConsumed(); } + + public function testGetTablesFull(): void + { + $GLOBALS['cfg']['Server']['DisableIS'] = true; + + $expected = [ + 'test_table' => [ + 'Name' => 'test_table', + 'Engine' => 'InnoDB', + 'Version' => '10', + 'Row_format' => 'Dynamic', + 'Rows' => '3', + 'Avg_row_length' => '5461', + 'Data_length' => '16384', + 'Max_data_length' => '0', + 'Index_length' => '0', + 'Data_free' => '0', + 'Auto_increment' => '4', + 'Create_time' => '2011-12-13 14:15:16', + 'Update_time' => null, + 'Check_time' => null, + 'Collation' => 'utf8mb4_general_ci', + 'Checksum' => null, + 'Create_options' => '', + 'Comment' => '', + 'Max_index_length' => '0', + 'Temporary' => 'N', + 'Type' => 'InnoDB', + 'TABLE_SCHEMA' => 'test_db', + 'TABLE_NAME' => 'test_table', + 'ENGINE' => 'InnoDB', + 'VERSION' => '10', + 'ROW_FORMAT' => 'Dynamic', + 'TABLE_ROWS' => '3', + 'AVG_ROW_LENGTH' => '5461', + 'DATA_LENGTH' => '16384', + 'MAX_DATA_LENGTH' => '0', + 'INDEX_LENGTH' => '0', + 'DATA_FREE' => '0', + 'AUTO_INCREMENT' => '4', + 'CREATE_TIME' => '2011-12-13 14:15:16', + 'UPDATE_TIME' => null, + 'CHECK_TIME' => null, + 'TABLE_COLLATION' => 'utf8mb4_general_ci', + 'CHECKSUM' => null, + 'CREATE_OPTIONS' => '', + 'TABLE_COMMENT' => '', + 'TABLE_TYPE' => 'BASE TABLE', + ], + ]; + + $actual = $this->dbi->getTablesFull('test_db'); + $this->assertEquals($expected, $actual); + } + + public function testGetTablesFullWithInformationSchema(): void + { + $GLOBALS['cfg']['Server']['DisableIS'] = false; + + $expected = [ + 'test_table' => [ + 'TABLE_CATALOG' => 'def', + 'TABLE_SCHEMA' => 'test_db', + 'TABLE_NAME' => 'test_table', + 'TABLE_TYPE' => 'BASE TABLE', + 'ENGINE' => 'InnoDB', + 'VERSION' => '10', + 'ROW_FORMAT' => 'Dynamic', + 'TABLE_ROWS' => '3', + 'AVG_ROW_LENGTH' => '5461', + 'DATA_LENGTH' => '16384', + 'MAX_DATA_LENGTH' => '0', + 'INDEX_LENGTH' => '0', + 'DATA_FREE' => '0', + 'AUTO_INCREMENT' => '4', + 'CREATE_TIME' => '2011-12-13 14:15:16', + 'UPDATE_TIME' => null, + 'CHECK_TIME' => null, + 'TABLE_COLLATION' => 'utf8mb4_general_ci', + 'CHECKSUM' => null, + 'CREATE_OPTIONS' => '', + 'TABLE_COMMENT' => '', + 'MAX_INDEX_LENGTH' => '0', + 'TEMPORARY' => 'N', + 'Db' => 'test_db', + 'Name' => 'test_table', + 'Engine' => 'InnoDB', + 'Type' => 'InnoDB', + 'Version' => '10', + 'Row_format' => 'Dynamic', + 'Rows' => '3', + 'Avg_row_length' => '5461', + 'Data_length' => '16384', + 'Max_data_length' => '0', + 'Index_length' => '0', + 'Data_free' => '0', + 'Auto_increment' => '4', + 'Create_time' => '2011-12-13 14:15:16', + 'Update_time' => null, + 'Check_time' => null, + 'Collation' => 'utf8mb4_general_ci', + 'Checksum' => null, + 'Create_options' => '', + 'Comment' => '', + ], + ]; + + $actual = $this->dbi->getTablesFull('test_db'); + $this->assertEquals($expected, $actual); + } } diff --git a/test/classes/Stubs/DbiDummy.php b/test/classes/Stubs/DbiDummy.php index 90fafabaef..47ae703664 100644 --- a/test/classes/Stubs/DbiDummy.php +++ b/test/classes/Stubs/DbiDummy.php @@ -2789,6 +2789,162 @@ class DbiDummy implements DbiExtension 'query' => 'CREATE DATABASE `test_db` DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;', 'result' => [], ], + [ + 'query' => 'SHOW TABLE STATUS FROM `test_db`', + 'columns' => [ + 'Name', + 'Engine', + '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', + 'Max_index_length', + 'Temporary', + ], + 'result' => [ + [ + 'test_table', + 'InnoDB', + '10', + 'Dynamic', + '3', + '5461', + '16384', + '0', + '0', + '0', + '4', + '2011-12-13 14:15:16', + null, + null, + 'utf8mb4_general_ci', + null, + '', + '', + '0', + 'N', + ], + ], + ], + [ + '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 (\'test_db\') 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', + 'MAX_INDEX_LENGTH', + 'TEMPORARY', + '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' => [ + [ + 'def', + 'test_db', + 'test_table', + 'BASE TABLE', + 'InnoDB', + '10', + 'Dynamic', + '3', + '5461', + '16384', + '0', + '0', + '0', + '4', + '2011-12-13 14:15:16', + null, + null, + 'utf8mb4_general_ci', + null, + '', + '', + '0', + 'N', + 'test_db', + 'test_table', + 'BASE TABLE', + 'InnoDB', + 'InnoDB', + '10', + 'Dynamic', + '3', + '5461', + '16384', + '0', + '0', + '0', + '4', + '2011-12-13 14:15:16', + null, + null, + 'utf8mb4_general_ci', + null, + '', + '', + ], + ], + ], ]; /** * Current database. |