diff --git a/libraries/dbi/dummy.lib.php b/libraries/dbi/dummy.lib.php index 83d92132bc..32150fcc33 100644 --- a/libraries/dbi/dummy.lib.php +++ b/libraries/dbi/dummy.lib.php @@ -111,6 +111,10 @@ $GLOBALS['dummy_queries'] = array( array('o', 'int(11)', 'NO', 'MUL', 'NULL', ''), ) ), + array( + 'query' => 'SHOW INDEXES FROM `pma_test`.`table1` WHERE (Non_unique = 0)', + 'result' => array(), + ), array( 'query' => 'SHOW COLUMNS FROM `pma_test`.`table2`', 'columns' => array( @@ -213,6 +217,14 @@ $GLOBALS['dummy_queries'] = array( 'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.`TABLE_PRIVILEGES` WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\' AND PRIVILEGE_TYPE=\'EVENT\' AND TABLE_SCHEMA=\'pma\\\\_test\' AND TABLE_NAME=\'table1\'', 'result' => array(), ), + array( + 'query' => 'RENAME TABLE `pma_test`.`table1` TO `pma_test`.`table3`;', + 'result' => array(), + ), + array( + 'query' => 'SELECT TRIGGER_SCHEMA, TRIGGER_NAME, EVENT_MANIPULATION, EVENT_OBJECT_TABLE, ACTION_TIMING, ACTION_STATEMENT, EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE, DEFINER FROM information_schema.TRIGGERS WHERE TRIGGER_SCHEMA= \'pma_test\' AND EVENT_OBJECT_TABLE = \'table1\';', + 'result' => array(), + ), ); /** diff --git a/test/classes/PMA_Table_test.php b/test/classes/PMA_Table_test.php new file mode 100644 index 0000000000..6c2033d4e4 --- /dev/null +++ b/test/classes/PMA_Table_test.php @@ -0,0 +1,134 @@ +assertInstanceOf('PMA_Table', $table); + } + + /** + * Test renaming + * + * @return void + */ + public function testRename() + { + $table = new PMA_Table('table1', 'pma_test'); + $table->rename('table3'); + $this->assertEquals('table3', $table->getName()); + } + + /** + * Test getting columns + * + * @return void + */ + public function testColumns() + { + $table = new PMA_Table('table1', 'pma_test'); + $this->assertEquals( + array('`pma_test`.`table1`.`i`', '`pma_test`.`table1`.`o`'), + $table->getColumns() + ); + } + + /** + * Test getting unique columns + * + * @return void + */ + public function testUniqueColumns() + { + $table = new PMA_Table('table1', 'pma_test'); + $this->assertEquals( + array(), + $table->getUniqueColumns() + ); + } + + /** + * Test name validation + * + * @param string $name name to test + * @param boolena $result expected result + * + * @return void + * + * @dataProvider dataValidateName + */ + public function testValidateName($name, $result) + { + $this->assertEquals( + $result, + PMA_Table::isValidName($name) + ); + } + + /** + * Data provider for name validation + * + * @return array with test data + */ + public function dataValidateName() + { + return array( + array('test', True), + array('te/st', False), + array('te.st', False), + array('te\\st', False), + ); + } +} +