diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 5353266b0a..fe2a801432 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -785,9 +785,6 @@ - - - diff --git a/tests/unit/Controllers/Database/Fixtures/Import-testController.html b/tests/unit/Controllers/Database/Fixtures/Import-testController.html new file mode 100644 index 0000000000..16c4290cba --- /dev/null +++ b/tests/unit/Controllers/Database/Fixtures/Import-testController.html @@ -0,0 +1,803 @@ + + + + Importing into the database "test_db" + + + + + + + + + + + Import defaults + + + SQL + + + CSV + + + OpenDocument + + + + + + + Import defaults + Customize default common import options. + + + Import defaults + + + + + + Format of imported file + + + + Default format; be aware that this list depends on location (database, table) and only SQL is always available. + + + + + csv + docsql + ldi + sql + + + + + + + + + + + + Character set of the file + + + + + + + + + iso-8859-1 + iso-8859-2 + iso-8859-3 + iso-8859-4 + iso-8859-5 + iso-8859-6 + iso-8859-7 + iso-8859-8 + iso-8859-9 + iso-8859-10 + iso-8859-11 + iso-8859-12 + iso-8859-13 + iso-8859-14 + iso-8859-15 + windows-1250 + windows-1251 + windows-1252 + windows-1256 + windows-1257 + koi8-r + big5 + gb2312 + utf-16 + utf-8 + utf-7 + x-user-defined + euc-jp + ks_c_5601-1987 + tis-620 + SHIFT_JIS + SJIS + SJIS-win + + + + + + + + + + + + Partial import: allow interrupt + + + + Allow interrupt of import in case script detects it is close to time limit. This might be a good way to import large files, however it can break transactions. + + + + + + + + + + + + + + + + + Partial import: skip queries + + + + Number of queries to skip from start. + + + + + + + + + + + + + + + Enable drag and drop import + + + + + + + Uncheck the checkbox to disable drag and drop import + + + + + + + + + + + + + + + + + + + + + + + + + SQL + Customize default options. + + + SQL + + + + + + SQL compatibility mode + + + + + + + + NONE + ANSI + DB2 + MAXDB + MYSQL323 + MYSQL40 + MSSQL + ORACLE + TRADITIONAL + + + + + + + + + + + + Do not use AUTO_INCREMENT for zero values + + + + + + + + + + + + + + + + + + + + Read as multibytes + + + + + + + + + + + + + + + + + + + + + + + + + + + + CSV + Customize default options. + + + CSV + + + + + + CSV + + + + + Add ON DUPLICATE KEY UPDATE + + + + Update data when duplicate keys found on import + + + + + + + + + + + + + + + + + Do not abort on INSERT error + + + + + + + + + + + + + + + + + + + + Columns terminated with + + + + + + + + + + + + + + + + + + Columns enclosed with + + + + + + + + + + + + + + + + + + Columns escaped with + + + + + + + + + + + + + + + + + + Lines terminated with + + + + + + + + + + + + + + + + + + + + CSV using LOAD DATA + + + + + Add ON DUPLICATE KEY UPDATE + + + + Update data when duplicate keys found on import + + + + + + + + + + + + + + + + + Do not abort on INSERT error + + + + + + + + + + + + + + + + + + + + Columns terminated with + + + + + + + + + + + + + + + + + + Columns enclosed with + + + + + + + + + + + + + + + + + + Columns escaped with + + + + + + + + + + + + + + + + + + Use LOCAL keyword + + + + + + + + auto + Yes + No + + + + + + + + + + + + + + + + + + + + OpenDocument + Customize default options. + + + OpenDocument + + + + + + OpenDocument Spreadsheet + + + + + Column names in first row + + + + + + + + + + + + + + + + + + + + Do not import empty rows + + + + + + + + + + + + + + + + + + + + Import percentages as proper decimals (12.00% to .12) + + + + + + + + + + + + + + + + + + + + Import currencies ($5.00 to 5.00) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + File to import: + + + File may be compressed (gzip, bzip2, zip) or uncompressed. + A compressed file's name must end in .[format].[compression]. Example: .sql.zip + + + + Browse your computer: (Max: 2,048KiB) + + + + + You may also drag and drop a file on any page. + + Character set of the file: + + iso-8859-1 + iso-8859-2 + iso-8859-3 + iso-8859-4 + iso-8859-5 + iso-8859-6 + iso-8859-7 + iso-8859-8 + iso-8859-9 + iso-8859-10 + iso-8859-11 + iso-8859-12 + iso-8859-13 + iso-8859-14 + iso-8859-15 + windows-1250 + windows-1251 + windows-1252 + windows-1256 + windows-1257 + koi8-r + big5 + gb2312 + utf-16 + utf-8 + utf-7 + x-user-defined + euc-jp + ks_c_5601-1987 + tis-620 + SHIFT_JIS + SJIS + SJIS-win + + + + + + Partial import: + + + + + + Allow the interruption of an import in case the script detects it is close to the PHP timeout limit. + + This might be a good way to import large files, however it can break transactions. + + + Skip this number of queries (for SQL) starting from the first one: + + + + + + Other options + + + + + Enable foreign key checks + + + + + + Format + + + CSV + ESRI Shape File + MediaWiki Table + OpenDocument Spreadsheet + SQL + XML + + + + + + + + Format-specific options: + + CSV + +Update data when duplicate keys found on import (add ON DUPLICATE KEY UPDATE) +Columns separated with: +Columns enclosed with: +Columns escaped with: +Lines terminated with: +Name of the new table (optional): +Import these many number of rows (optional): +The first line of the file contains the table column names (if this is unchecked, the first line will become part of the data) +Do not abort on INSERT error + + + +ESRI Shape FileThis format has no options + +MediaWiki TableThis format has no options + +OpenDocument Spreadsheet + +The first line of the file contains the table column names (if this is unchecked, the first line will become part of the data) +Do not import empty rows +Import percentages as proper decimals (ex. 12.00% to .12) +Import currencies (ex. $5.00 to 5.00) + + + +SQL + +SQL compatibility mode:NONEANSIDB2MAXDBMYSQL323MYSQL40MSSQLORACLETRADITIONAL +Do not use AUTO_INCREMENT for zero values + + + +XMLThis format has no options + + + + + + + + + + + + diff --git a/tests/unit/Controllers/Database/ImportControllerTest.php b/tests/unit/Controllers/Database/ImportControllerTest.php new file mode 100644 index 0000000000..3466428518 --- /dev/null +++ b/tests/unit/Controllers/Database/ImportControllerTest.php @@ -0,0 +1,63 @@ +createDbiDummy(); + $dbiDummy->addSelectDb('test_db'); + + $request = ServerRequestFactory::create()->createServerRequest('GET', 'https://example.com/') + ->withQueryParams(['route' => '/database/import', 'db' => 'test_db']); + + $response = ($this->getImportController($dbiDummy))($request); + + $dbiDummy->assertAllSelectsConsumed(); + self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); + self::assertStringEqualsFile( + __DIR__ . '/Fixtures/Import-testController.html', + (string) $response->getBody(), + ); + } + + private function getImportController(DbiDummy $dbiDummy): ImportController + { + $config = new Config(); + $dbi = $this->createDatabaseInterface($dbiDummy, $config); + $relation = new Relation($dbi, $config); + $userPreferences = new UserPreferences($dbi, $relation, new Template($config), $config, new Clock()); + $responseRenderer = new ResponseRenderer(); + + return new ImportController( + $responseRenderer, + $dbi, + new PageSettings($userPreferences, $responseRenderer), + new DbTableExists($dbi), + $config, + ); + } +}
+ File may be compressed (gzip, bzip2, zip) or uncompressed. + A compressed file's name must end in .[format].[compression]. Example: .sql.zip +
You may also drag and drop a file on any page.
This format has no options
AUTO_INCREMENT