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 @@ +
+

+ Import + Importing into the database "test_db"

+ + +
+ + + + + + +
+
+
+
+
Import defaults
+
Customize default common import options.
+ +
+ Import defaults + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + Default format; be aware that this list depends on location (database, table) and only SQL is always available. + + + + + + Restore default value + +
+ + + + + + + + + + Restore default value + +
+ + + + + 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. + + + + + + + + Restore default value + +
+ + + + + Number of queries to skip from start. + + + + + + Restore default value + +
+ + + + Documentation + + + + Uncheck the checkbox to disable drag and drop import + + + + + + + + Restore default value + +
+
+
+ +
+
+
+
+
+
SQL
+
Customize default options.
+ +
+ SQL + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + Restore default value + +
+ + + + + + + + + + + + Restore default value + +
+ + + + + + + + + + + + Restore default value + +
+
+
+ +
+
+
+
+
+
CSV
+
Customize default options.
+ +
+ CSV + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ CSV +
+ + + + + Update data when duplicate keys found on import + + + + + + + + Restore default value + +
+ + + + + + + + + + + + Restore default value + +
+ + + + + + + + + + Restore default value + +
+ + + + + + + + + + Restore default value + +
+ + + + + + + + + + Restore default value + +
+ + + + + + + + + + + + Restore default value + +
+ CSV using LOAD DATA +
+ + + + + Update data when duplicate keys found on import + + + + + + + + Restore default value + +
+ + + + + + + + + + + + Restore default value + +
+ + + + + + + + + + Restore default value + +
+ + + + + + + + + + Restore default value + +
+ + + + + + + + + + Restore default value + +
+ + + + + + + + + + Restore default value + +
+
+
+ +
+
+
+
+
+
OpenDocument
+
Customize default options.
+ +
+ OpenDocument + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ OpenDocument Spreadsheet +
+ + + + + + + + + + + + Restore default value + +
+ + + + + + + + + + + + Restore default value + +
+ + + + + + + + + + + + Restore default value + +
+ + + + + + + + + + + + Restore default value + +
+
+
+ +
+
+
+
+ + +
+ + +
+ +
+ +
+ ajax clock + +
+ + +
+
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 +

+ +
+ + +
+
+
+

You may also drag and drop a file on any page.

+ + + +
+
+ +
+
Partial import:
+
+ +
+ + +
This might be a good way to import large files, however it can break transactions.
+
+ + + +
+
+ +
+
Other options
+
+ +
+ + +
+
+
+ +
+
Format
+
+ + +
+
+
+ +
+
Format-specific options:
+
+

CSV

+
    +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
+
+ +

ESRI Shape File

This format has no options

+ +

MediaWiki Table

This format has no options

+ +

OpenDocument Spreadsheet

+
    +
  • +
  • +
  • +
  • +
+
+ +

SQL

+
    +
  • Documentation +
  • Documentation +
+
+ +

XML

This 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, + ); + } +}