diff --git a/libraries/dbi/dummy.lib.php b/libraries/dbi/dummy.lib.php index db06853b69..4894a2dcbd 100644 --- a/libraries/dbi/dummy.lib.php +++ b/libraries/dbi/dummy.lib.php @@ -79,6 +79,12 @@ $GLOBALS['dummy_queries'] = array( array('table2'), ) ), + array( + 'query' => 'SHOW TABLES FROM `pmadb`', + 'result' => array( + array('column_info'), + ) + ), array( 'query' => 'SHOW COLUMNS FROM `pma_test`.`table1`', 'columns' => array( @@ -114,7 +120,7 @@ $GLOBALS['dummy_queries'] = array( ), 'result' => array( array('i', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment', 'select,insert,update,references', ''), - array('o', 'int(11)', 'NO', 'MUL', 'NULL', '', 'select,insert,update,references', ''), + array('o', 'varchar(100)', 'NO', 'MUL', 'NULL', '', 'select,insert,update,references', ''), ) ), array( @@ -143,6 +149,13 @@ $GLOBALS['dummy_queries'] = array( 'columns' => array('f'), 'result' => array(array('ROT13')), ), + array( + 'query' => 'SELECT `column_name`, `mimetype`, `transformation`, `transformation_options` FROM `pmadb`.`column_info` WHERE `db_name` = \'pma_test\' AND `table_name` = \'table1\' AND ( `mimetype` != \'\' OR `transformation` != \'\' OR `transformation_options` != \'\')', + 'columns' => array('column_name', 'mimetype', 'transformation', 'transformation_options'), + 'result' => array( + array('o', 'text/plain', 'sql'), + ) + ), ); /** @@ -201,7 +214,8 @@ function PMA_DBI_connect( */ function PMA_DBI_select_db($dbname, $link = null) { - return $GLOBALS['dummy_db']; + $GLOBALS['dummy_db'] = $dbname; + return true; } /** diff --git a/test/libraries/PMA_transformation_test.php b/test/libraries/PMA_transformation_test.php index d68dff865a..38dabe12ba 100644 --- a/test/libraries/PMA_transformation_test.php +++ b/test/libraries/PMA_transformation_test.php @@ -10,6 +10,11 @@ * Include to test. */ require_once 'libraries/transformations.lib.php'; +require_once 'libraries/CommonFunctions.class.php'; +require_once 'libraries/database_interface.lib.php'; +require_once 'libraries/Tracker.class.php'; +require_once 'libraries/relation.lib.php'; +require_once 'libraries/Theme.class.php'; /** * tests for transformation wrappers @@ -19,6 +24,35 @@ require_once 'libraries/transformations.lib.php'; class PMA_Transformation_Test extends PHPUnit_Framework_TestCase { + /** + * Set up global environment. + * + * @return void + */ + public function setup() + { + $GLOBALS['table'] = 'table'; + $GLOBALS['db'] = 'db'; + $_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme'); + $_SESSION[' PMA_token '] = 'token'; + $GLOBALS['cfg'] = array( + 'MySQLManualType' => 'none', + 'AjaxEnable' => true, + 'ServerDefault' => 1, + 'PropertiesIconic' => true, + ); + $GLOBALS['server'] = 1; + $GLOBALS['cfg']['Server']['pmadb'] = 'pmadb'; + $GLOBALS['cfg']['Server']['user'] = 'user'; + $GLOBALS['cfg']['Server']['bookmarktable'] = ''; + $GLOBALS['cfg']['Server']['relation'] = ''; + $GLOBALS['cfg']['Server']['table_info'] = ''; + $GLOBALS['cfg']['Server']['table_coords'] = ''; + $GLOBALS['cfg']['Server']['designer_coords'] = ''; + $GLOBALS['cfg']['Server']['column_info'] = 'column_info'; + $GLOBALS['cfg']['DBG']['sql'] = false; + } + /** * Test for parsing options. * @@ -104,5 +138,22 @@ class PMA_Transformation_Test extends PHPUnit_Framework_TestCase PMA_getAvailableMIMEtypes() ); } + + /** + * Tests getting mime types for table + * + * @return void + */ + public function testGetMime() + { + $this->assertEquals( + array('o' => array( + 'column_name' => 'o', + 'mimetype' => 'Text/plain', + 'transformation' => 'Sql', + )), + PMA_getMIME('pma_test', 'table1') + ); + } } ?>