diff --git a/config/import.php b/config/import.php index 05aec936..e64b3897 100644 --- a/config/import.php +++ b/config/import.php @@ -27,7 +27,7 @@ return [ | */ - 'zip_max_files' => (int) (env('IMPORT_ZIP_MAX_FILES') ?: 100), + 'zip_max_files' => (int) (env('IMPORT_ZIP_MAX_FILES') ?: 10000), 'zip_max_uncompressed_size' => (int) (env('IMPORT_ZIP_MAX_UNCOMPRESSED_SIZE') ?: 500 * 1024 * 1024), diff --git a/tests/Unit/Service/Import/Importers/ZipImportHelperTest.php b/tests/Unit/Service/Import/Importers/ZipImportHelperTest.php index 0e818552..f4da449e 100644 --- a/tests/Unit/Service/Import/Importers/ZipImportHelperTest.php +++ b/tests/Unit/Service/Import/Importers/ZipImportHelperTest.php @@ -88,6 +88,30 @@ class ZipImportHelperTest extends TestCase $this->fail(); } + public function test_extract_with_default_limit_allows_toggl_export_with_many_projects(): void + { + // Arrange + // Toggl exports contain one projects_users and one tasks file per project + $files = [ + 'clients.json' => '[]', + 'projects.json' => '[]', + 'tags.json' => '[]', + 'workspace_users.json' => '[]', + ]; + for ($project = 1; $project <= 2000; $project++) { + $files['projects_users/'.$project.'.json'] = '[]'; + $files['tasks/'.$project.'.json'] = '[]'; + } + $zipPath = $this->createZip($files); + + // Act + app(ZipImportHelper::class)->extract($zipPath, $this->targetDirectory->path()); + + // Assert + $this->assertSame('[]', file_get_contents($this->targetDirectory->path('projects_users/2000.json'))); + $this->assertSame('[]', file_get_contents($this->targetDirectory->path('tasks/2000.json'))); + } + public function test_extract_throws_exception_if_zip_contains_too_many_files(): void { // Arrange