getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() ->getMock(); //this data is needed when PMA_ServerStatusData constructs $server_session_variable = array( "auto_increment_increment" => "1", "auto_increment_offset" => "13", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF", ); $server_global_variables = array( "auto_increment_increment" => "0", "auto_increment_offset" => "12" ); $fetchResult = array( array( "SHOW SESSION VARIABLES;", 0, 1, null, 0, $server_session_variable ), array( "SHOW GLOBAL VARIABLES;", 0, 1, null, 0, $server_global_variables ) ); $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValueMap($fetchResult)); $GLOBALS['dbi'] = $dbi; } /** * Test for PMA_formatVariable * * @return void */ public function testPMAFormatVariable() { //Call the test function $name_for_value_byte = "binlog_cache_size"; $name_for_value_not_byte = "auto_increment_increment"; $name_for_value_not_num = "PMA_key"; $variable_doc_links = PMA_getArrayForDocumentLinks(); //name is_numeric and the value type is byte $this->assertEquals( '3 B', PMA_formatVariable($name_for_value_byte, "3", $variable_doc_links) ); //name is_numeric and the value type is not byte $this->assertEquals( '3', PMA_formatVariable($name_for_value_not_byte, "3", $variable_doc_links) ); //value is not a number $this->assertEquals( 'value', PMA_formatVariable($name_for_value_not_num, "value", $variable_doc_links) ); } /** * Test for PMA_getHtmlForLinkTemplates * * @return void */ public function testPMAGetHtmlForLinkTemplates() { //Call the test function $html = PMA_getHtmlForLinkTemplates(); $url = 'server_variables.php' . PMA_URL_getCommon(array()); //validate 1: URL $this->assertContains( $url, $html ); //validate 2: images $this->assertContains( PMA_Util::getIcon('b_save.png', __('Save')), $html ); $this->assertContains( PMA_Util::getIcon('b_close.png', __('Cancel')), $html ); } /** * Test for PMA_getHtmlForServerVariables * * @return void */ public function testPMAGetHtmlForServerVariables() { //Call the test function $_REQUEST['filter'] = "auto-commit"; $variable_doc_links = PMA_getArrayForDocumentLinks(); $html = PMA_getHtmlForServerVariables($variable_doc_links); //validate 1: Filters $this->assertContains( '', $html ); $this->assertContains( __('Containing the word:'), $html ); $this->assertContains( $_REQUEST['filter'], $html ); //validate 2: Server Variables $this->assertContains( '