Fix Table\ImportControllerTest failing test
[phpmyadmin.git] / test / classes / Controllers / Table / ImportControllerTest.php
blobd2c039c9fc65824232af6175b99b96f9c6715c7d
1 <?php
3 declare(strict_types=1);
5 namespace PhpMyAdmin\Tests\Controllers\Table;
7 use PhpMyAdmin\Charsets;
8 use PhpMyAdmin\Config\PageSettings;
9 use PhpMyAdmin\Controllers\Table\ImportController;
10 use PhpMyAdmin\Encoding;
11 use PhpMyAdmin\Plugins;
12 use PhpMyAdmin\Template;
13 use PhpMyAdmin\Tests\AbstractTestCase;
14 use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
16 /**
17 * @covers \PhpMyAdmin\Controllers\Table\ImportController
19 class ImportControllerTest extends AbstractTestCase
21 public function testImportController(): void
23 $GLOBALS['server'] = 2;
24 $GLOBALS['db'] = 'test_db';
25 $GLOBALS['table'] = 'test_table';
26 $GLOBALS['text_dir'] = 'ltr';
27 $GLOBALS['lang'] = 'en';
28 $GLOBALS['PMA_PHP_SELF'] = 'index.php';
29 $GLOBALS['cfg']['Server'] = $GLOBALS['config']->defaultServer;
30 $_GET['format'] = 'xml';
32 $this->dummyDbi->addSelectDb('test_db');
33 $this->dummyDbi->addResult('SHOW TABLES LIKE \'test_table\';', [['test_table']]);
34 $this->dummyDbi->addResult('SELECT @@local_infile;', [['1']]);
36 $importList = Plugins::getImport('table');
37 $choice = Plugins::getChoice($importList, 'xml');
38 $options = Plugins::getOptions('Import', $importList);
40 $pageSettings = new PageSettings('Import');
41 $template = new Template();
42 $expected = $template->render('table/import/index', [
43 'page_settings_error_html' => $pageSettings->getErrorHTML(),
44 'page_settings_html' => $pageSettings->getHTML(),
45 'upload_id' => 'abc1234567890',
46 'handler' => 'PhpMyAdmin\Plugins\Import\Upload\UploadNoplugin',
47 'hidden_inputs' => [
48 'noplugin' => 'abc1234567890',
49 'import_type' => 'table',
50 'db' => 'test_db',
51 'table' => 'test_table',
53 'db' => 'test_db',
54 'table' => 'test_table',
55 'max_upload_size' => 2097152,
56 'formatted_maximum_upload_size' => '(Max: 2,048KiB)',
57 'plugins_choice' => $choice,
58 'options' => $options,
59 'skip_queries_default' => '0',
60 'is_allow_interrupt_checked' => ' checked="checked"',
61 'local_import_file' => null,
62 'is_upload' => true,
63 'upload_dir' => '',
64 'timeout_passed_global' => null,
65 'compressions' => ['gzip', 'bzip2', 'zip'],
66 'is_encoding_supported' => true,
67 'encodings' => Encoding::listEncodings(),
68 'import_charset' => '',
69 'timeout_passed' => null,
70 'offset' => null,
71 'can_convert_kanji' => false,
72 'charsets' => Charsets::getCharsets($this->dbi, false),
73 'is_foreign_key_check' => true,
74 'user_upload_dir' => '',
75 'local_files' => '',
76 ]);
78 $response = new ResponseRenderer();
79 (new ImportController($response, $template, $this->dbi))();
80 $this->assertSame($expected, $response->getHTMLResult());