/** * Prepares environment for the test. * * @return void */ public function setUp() { //$_REQUEST $_REQUEST['log'] = "index1"; $_REQUEST['pos'] = 3; //$GLOBALS $GLOBALS['cfg']['MaxRows'] = 10; $GLOBALS['server'] = 1; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; $GLOBALS['cfg']['SQP'] = array(); $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; $GLOBALS['cfg']['LimitChars'] = 100; $GLOBALS['table'] = "table"; $GLOBALS['pmaThemeImage'] = 'image'; //$_SESSION $_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new Theme(); Util::cacheSet('profiling_supported', true); $binary_log_file_names = array(); $binary_log_file_names[] = array("Log_name" => "index1", "File_size" => 100); $binary_log_file_names[] = array("Log_name" => "index2", "File_size" => 200); //Mock DBI $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock(); $dbi->expects($this->once())->method('fetchResult')->will($this->returnValue($binary_log_file_names)); $container = Container::getDefaultContainer(); $container->set('dbi', $dbi); }
/** * Checks if this database server is running on Amazon RDS. * * @return boolean */ public function isAmazonRds() { if (Util::cacheExists('is_amazon_rds')) { return Util::cacheGet('is_amazon_rds'); } $sql = 'SELECT @@basedir'; $result = $this->fetchResult($sql); $rds = $result[0] == '/rdsdbbin/mysql/'; Util::cacheSet('is_amazon_rds', $rds); return $rds; }
/** * Test for rename * * @return void */ public function testRename() { $table = 'PMA_BookMark'; $db = 'PMA'; Util::cacheSet('lower_case_table_names', false); $table = new Table($table, $db); //rename to same name $table_new = 'PMA_BookMark'; $result = $table->rename($table_new); $this->assertEquals(true, $result); //isValidName //space in table name $table_new = 'PMA_BookMark '; $result = $table->rename($table_new); $this->assertEquals(false, $result); //empty name $table_new = ''; $result = $table->rename($table_new); $this->assertEquals(false, $result); //dot in table name $table_new = 'PMA_.BookMark'; $result = $table->rename($table_new); $this->assertEquals(false, $result); $table_new = 'PMA_BookMark_new'; $db_new = 'PMA_new'; $result = $table->rename($table_new, $db_new); $this->assertEquals(true, $result); //message $this->assertEquals("Table PMA_BookMark has been renamed to PMA_BookMark_new.", $table->getLastMessage()); }
/** * Returns the server tabs as an array * * @return array Data for generating server tabs */ private function _getServerTabs() { $is_superuser = $GLOBALS['dbi']->isSuperuser(); $isCreateOrGrantUser = $GLOBALS['dbi']->isUserType('grant') || $GLOBALS['dbi']->isUserType('create'); if (Util::cacheExists('binary_logs')) { $binary_logs = Util::cacheGet('binary_logs'); } else { $binary_logs = $GLOBALS['dbi']->fetchResult('SHOW MASTER LOGS', 'Log_name', null, null, DatabaseInterface::QUERY_STORE); Util::cacheSet('binary_logs', $binary_logs); } $tabs = array(); $tabs['databases']['icon'] = 's_db.png'; $tabs['databases']['link'] = 'server_databases.php'; $tabs['databases']['text'] = __('Databases'); $tabs['sql']['icon'] = 'b_sql.png'; $tabs['sql']['link'] = 'server_sql.php'; $tabs['sql']['text'] = __('SQL'); $tabs['status']['icon'] = 's_status.png'; $tabs['status']['link'] = 'server_status.php'; $tabs['status']['text'] = __('Status'); $tabs['status']['active'] = in_array(basename($GLOBALS['PMA_PHP_SELF']), array('server_status.php', 'server_status_advisor.php', 'server_status_monitor.php', 'server_status_queries.php', 'server_status_variables.php', 'server_status_processes.php')); if ($is_superuser || $isCreateOrGrantUser) { $tabs['rights']['icon'] = 's_rights.png'; $tabs['rights']['link'] = 'server_privileges.php'; $tabs['rights']['text'] = __('User accounts'); $tabs['rights']['active'] = in_array(basename($GLOBALS['PMA_PHP_SELF']), array('server_privileges.php', 'server_user_groups.php')); $tabs['rights']['args']['viewing_mode'] = 'server'; } $tabs['export']['icon'] = 'b_export.png'; $tabs['export']['link'] = 'server_export.php'; $tabs['export']['text'] = __('Export'); $tabs['import']['icon'] = 'b_import.png'; $tabs['import']['link'] = 'server_import.php'; $tabs['import']['text'] = __('Import'); $tabs['settings']['icon'] = 'b_tblops.png'; $tabs['settings']['link'] = 'prefs_manage.php'; $tabs['settings']['text'] = __('Settings'); $tabs['settings']['active'] = in_array(basename($GLOBALS['PMA_PHP_SELF']), array('prefs_forms.php', 'prefs_manage.php')); if (!empty($binary_logs)) { $tabs['binlog']['icon'] = 's_tbl.png'; $tabs['binlog']['link'] = 'server_binlog.php'; $tabs['binlog']['text'] = __('Binary log'); } if ($is_superuser) { $tabs['replication']['icon'] = 's_replication.png'; $tabs['replication']['link'] = 'server_replication.php'; $tabs['replication']['text'] = __('Replication'); } $tabs['vars']['icon'] = 's_vars.png'; $tabs['vars']['link'] = 'server_variables.php'; $tabs['vars']['text'] = __('Variables'); $tabs['charset']['icon'] = 's_asci.png'; $tabs['charset']['link'] = 'server_collations.php'; $tabs['charset']['text'] = __('Charsets'); $tabs['engine']['icon'] = 'b_engine.png'; $tabs['engine']['link'] = 'server_engines.php'; $tabs['engine']['text'] = __('Engines'); $tabs['plugins']['icon'] = 'b_plugin.png'; $tabs['plugins']['link'] = 'server_plugins.php'; $tabs['plugins']['text'] = __('Plugins'); return $tabs; }