3 declare(strict_types
=1);
5 namespace PhpMyAdmin\Tests\Export
;
8 use PhpMyAdmin\ConfigStorage\Relation
;
9 use PhpMyAdmin\DatabaseInterface
;
10 use PhpMyAdmin\Encoding
;
11 use PhpMyAdmin\Export\Options
;
12 use PhpMyAdmin\Export\TemplateModel
;
13 use PhpMyAdmin\Plugins
;
14 use PhpMyAdmin\Tests\AbstractTestCase
;
18 * @covers \PhpMyAdmin\Export\Options
20 class OptionsTest
extends AbstractTestCase
25 protected function setUp(): void
28 parent
::setLanguage();
29 parent
::setGlobalConfig();
30 $GLOBALS['cfg']['Server']['host'] = 'localhost';
31 $GLOBALS['cfg']['Server']['user'] = 'pma_user';
32 $GLOBALS['server'] = 0;
34 $GLOBALS['table'] = 'table';
35 $GLOBALS['db'] = 'PMA';
37 $pmaconfig = $this->getMockBuilder(Config
::class)
38 ->disableOriginalConstructor()
41 $pmaconfig->expects($this->any())
42 ->method('getUserValue')
43 ->will($this->returnValue('user value for test'));
45 $GLOBALS['config'] = $pmaconfig;
47 $this->export
= new Options(
48 new Relation($GLOBALS['dbi']),
49 new TemplateModel($GLOBALS['dbi'])
53 public function testGetOptions(): void
55 $GLOBALS['cfg']['Export']['method'] = 'XML';
56 $GLOBALS['cfg']['SaveDir'] = '/tmp';
57 $GLOBALS['cfg']['ZipDump'] = false;
58 $GLOBALS['cfg']['GZipDump'] = false;
60 $export_type = 'server';
63 $num_tables_str = '10';
64 $unlim_num_rows_str = 'unlim_num_rows_str';
65 //$single_table = "single_table";
66 $GLOBALS['dbi']->getCache()->cacheTableContent([$db, $table, 'ENGINE'], 'MERGE');
69 'test_column1' => ['COLUMN_NAME' => 'test_column1'],
70 'test_column2' => ['COLUMN_NAME' => 'test_column2'],
72 $dbi = $this->getMockBuilder(DatabaseInterface
::class)
73 ->disableOriginalConstructor()
76 $dbi->expects($this->any())->method('getColumnsFull')
77 ->will($this->returnValue($columns_info));
78 $dbi->expects($this->any())->method('getCompatibilities')
79 ->will($this->returnValue([]));
81 $GLOBALS['dbi'] = $dbi;
83 $exportList = Plugins
::getExport($export_type, true);
84 $dropdown = Plugins
::getChoice($exportList, 'sql');
86 //Call the test function
87 $actual = $this->export
->getOptions(
98 'export_type' => $export_type,
110 'export_type' => $export_type,
111 'export_method' => $GLOBALS['cfg']['Export']['method'],
114 'export_method' => $GLOBALS['cfg']['Export']['method'],
115 'plugins_choice' => $dropdown,
116 'options' => Plugins
::getOptions('Export', $exportList),
117 'can_convert_kanji' => Encoding
::canConvertKanji(),
118 'exec_time_limit' => $GLOBALS['cfg']['ExecTimeLimit'],
120 'has_save_dir' => true,
121 'save_dir' => Util
::userDir($GLOBALS['cfg']['SaveDir']),
122 'export_is_checked' => $GLOBALS['cfg']['Export']['quick_export_onserver'],
123 'export_overwrite_is_checked' => $GLOBALS['cfg']['Export']['quick_export_onserver_overwrite'],
124 'has_aliases' => false,
126 'is_checked_lock_tables' => $GLOBALS['cfg']['Export']['lock_tables'],
127 'is_checked_asfile' => $GLOBALS['cfg']['Export']['asfile'],
128 'is_checked_as_separate_files' => $GLOBALS['cfg']['Export']['as_separate_files'],
129 'is_checked_export' => $GLOBALS['cfg']['Export']['onserver'],
130 'is_checked_export_overwrite' => $GLOBALS['cfg']['Export']['onserver_overwrite'],
131 'is_checked_remember_file_template' => $GLOBALS['cfg']['Export']['remember_file_template'],
134 'is_encoding_supported' => true,
135 'encodings' => Encoding
::listEncodings(),
136 'export_charset' => $GLOBALS['cfg']['Export']['charset'],
137 'export_asfile' => $GLOBALS['cfg']['Export']['asfile'],
138 'has_zip' => $GLOBALS['cfg']['ZipDump'],
139 'has_gzip' => $GLOBALS['cfg']['GZipDump'],
140 'selected_compression' => 'none',
141 'filename_template' => 'user value for test',
144 $this->assertIsArray($actual);
145 $this->assertEquals($expected, $actual);