getMockBuilder('PhpMyAdmin\Config') ->disableOriginalConstructor() ->getMock(); $pmaconfig->expects($this->any()) ->method('getUserValue') ->will($this->returnValue('user value for test')); $GLOBALS['PMA_Config'] = $pmaconfig; } /** * Test for Export::getHtmlForHiddenInput * * @return void */ public function testPMAGetHtmlForHiddenInput() { $export_type = "server"; $db = "PMA"; $table = "PMA_test"; $single_table_str = "PMA_single_str"; $sql_query_str = "sql_query_str"; //Call the test function $html = Export::getHtmlForHiddenInput( $export_type, $db, $table, $single_table_str, $sql_query_str ); //validate 1: Url::getHiddenInputs //$single_table $this->assertContains( 'assertContains( 'assertContains( 'cacheTableContent(array($db, $table, 'ENGINE'), 'MERGE'); $columns_info = array( 'test_column1' => array( 'COLUMN_NAME' => 'test_column1' ), 'test_column2' => array( 'COLUMN_NAME' => 'test_column2' ) ); $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); $dbi->expects($this->any())->method('getColumnsFull') ->will($this->returnValue($columns_info)); $dbi->expects($this->any())->method('getCompatibilities') ->will($this->returnValue(array())); $GLOBALS['dbi'] = $dbi; /* Scan for plugins */ $export_list = Plugins::getPlugins( "export", 'libraries/classes/Plugins/Export/', array( 'export_type' => $export_type, 'single_table' => isset($single_table) ) ); //Call the test function $html = Export::getHtmlForExportOptions( $export_type, $db, $table, $multi_values_str, $num_tables_str, $export_list, $unlim_num_rows_str ); //validate 2: Export::getHtmlForExportOptionsMethod $this->assertContains( $cfg['Export']['method'], $html ); $this->assertContains( '
', $html ); $this->assertContains( __('Export method:'), $html ); $this->assertContains( __('Custom - display all possible options'), $html ); //validate 3: Export::getHtmlForExportOptionsSelection $this->assertContains( '
', $html ); $this->assertContains( '

' . __('Databases:') . '

', $html ); $this->assertContains( $multi_values_str, $html ); //validate 4: Export::getHtmlForExportOptionsQuickExport $this->assertContains( 'assertContains( 'Save on server in the directory ' . $dir . '', $html ); //validate 5: Export::getHtmlForAliasModalDialog $this->assertContains( '
', $html ); $this->assertContains( 'Select database', $html ); $this->assertContains( 'Select table', $html ); $this->assertContains( 'New database name', $html ); $this->assertContains( 'New table name', $html ); //validate 6: Export::getHtmlForExportOptionsOutput $this->assertContains( '
', $html ); $this->assertContains( 'user value for test', $html ); //validate 7: Export::getHtmlForExportOptionsFormat $this->assertContains( '
', $html ); $this->assertContains( '

' . __('Format:') . '

', $html ); } /** * Test for Export::getHtmlForAliasModalDialog * * @return void */ public function testPMAGetHtmlForAliasModalDialog() { $columns_info = array( 'test\'_db' => array( 'test_table' => array( 'co"l1' => array( 'COLUMN_NAME' => 'co"l1' ), 'col<2' => array( 'COLUMN_NAME' => 'col<2' ) ) ) ); $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); $dbi->expects($this->any())->method('getColumnsFull') ->will($this->returnValue($columns_info)); $GLOBALS['dbi'] = $dbi; $html = Export::getHtmlForAliasModalDialog(); $this->assertContains( '
', $html ); $this->assertContains('