mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-06 12:02:45 +03:00
ZIP Imports/Exports: Fixed some lint and test issues
- Updated test handling to create imports folder when required. - Updated some tests to delete created import zip files.
This commit is contained in:
@@ -168,6 +168,8 @@ class ZipImportTest extends TestCase
|
||||
$resp->assertRedirect("/import/{$import->id}");
|
||||
$this->assertFileExists(storage_path($import->path));
|
||||
$this->assertActivityExists(ActivityType::IMPORT_CREATE);
|
||||
|
||||
ZipTestHelper::deleteZipForImport($import);
|
||||
}
|
||||
|
||||
public function test_import_show_page()
|
||||
@@ -325,6 +327,8 @@ class ZipImportTest extends TestCase
|
||||
$resp = $this->followRedirects($resp);
|
||||
$resp->assertSeeText('The name field is required.');
|
||||
$resp->assertSeeText('The id must be an integer.');
|
||||
|
||||
ZipTestHelper::deleteZipForImport($import);
|
||||
}
|
||||
|
||||
public function test_run_checks_permissions_on_import()
|
||||
@@ -340,6 +344,8 @@ class ZipImportTest extends TestCase
|
||||
|
||||
$resp = $this->followRedirects($resp);
|
||||
$resp->assertSeeText('You are lacking the required permissions to create books.');
|
||||
|
||||
ZipTestHelper::deleteZipForImport($import);
|
||||
}
|
||||
|
||||
public function test_run_requires_parent_for_chapter_and_page_imports()
|
||||
@@ -379,6 +385,8 @@ class ZipImportTest extends TestCase
|
||||
|
||||
$resp = $this->followRedirects($resp);
|
||||
$resp->assertSee('Parent book required for chapter import.');
|
||||
|
||||
ZipTestHelper::deleteZipForImport($import);
|
||||
}
|
||||
|
||||
protected function runImportFromFile(UploadedFile $file): TestResponse
|
||||
|
@@ -20,7 +20,14 @@ class ZipTestHelper
|
||||
|
||||
$import = Import::factory()->create($importData);
|
||||
$zip = static::zipUploadFromData($zipData, $files);
|
||||
rename($zip->getRealPath(), storage_path($import->path));
|
||||
$targetPath = storage_path($import->path);
|
||||
$targetDir = dirname($targetPath);
|
||||
|
||||
if (!file_exists($targetDir)) {
|
||||
mkdir($targetDir);
|
||||
}
|
||||
|
||||
rename($zip->getRealPath(), $targetPath);
|
||||
|
||||
return $import;
|
||||
}
|
||||
|
Reference in New Issue
Block a user