mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-30 19:45:59 +00:00
zip unit testing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Domain\Zip\Actions;
|
||||
|
||||
use STS\ZipStream\ZipStream;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\File;
|
||||
@@ -27,14 +28,14 @@ class ZipFilesAction
|
||||
if (Storage::exists($filePath)) {
|
||||
// local disk
|
||||
if (is_storage_driver('local')) {
|
||||
$zip->add(storage_path("app/files/$file->user_id/$file->basename"), $file->name);
|
||||
$zip->add(Storage::path($filePath), $file->name);
|
||||
}
|
||||
|
||||
// s3 client
|
||||
if (is_storage_driver('s3')) {
|
||||
$bucketName = config('filesystems.disks.s3.bucket');
|
||||
|
||||
$zip->add("s3://$bucketName/files/$file->user_id/$file->basename", $file->name);
|
||||
$zip->add("s3://$bucketName/$filePath", $file->name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -41,14 +41,14 @@ class ZipFolderAction
|
||||
|
||||
// local disk
|
||||
if (is_storage_driver('local')) {
|
||||
$zip->add(storage_path("app/files/$user_id/{$file['basename']}"), $zipDestination);
|
||||
$zip->add(Storage::path($filePath), $zipDestination);
|
||||
}
|
||||
|
||||
// s3 client
|
||||
if (is_storage_driver('s3')) {
|
||||
$bucketName = config('filesystems.disks.s3.bucket');
|
||||
|
||||
$zip->add("s3://$bucketName/files/$user_id/{$file['basename']}", $zipDestination);
|
||||
$zip->add("s3://$bucketName/$filePath", $zipDestination);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Tests\Domain\Zip;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
use App\Users\Models\User;
|
||||
use Domain\Zip\Models\Zip;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\Files\Models\File;
|
||||
use Domain\Folders\Models\Folder;
|
||||
@@ -35,20 +34,14 @@ class UserZippingTest extends TestCase
|
||||
])->assertStatus(201);
|
||||
});
|
||||
|
||||
$file_ids = File::all()->pluck('id');
|
||||
$file_ids = File::all()->pluck('id')->toArray();
|
||||
|
||||
$this->postJson('/api/zip/files', [
|
||||
'items' => $file_ids,
|
||||
])->assertStatus(201);
|
||||
$ids = implode(',', $file_ids);
|
||||
|
||||
$this->assertDatabaseHas('zips', [
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
->assertExists(
|
||||
'zip/' . Zip::first()->basename
|
||||
);
|
||||
$this
|
||||
->getJson("/api/zip/files?ids=$ids")
|
||||
->assertStatus(200)
|
||||
->assertHeader('content-type', 'application/x-zip');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,15 +73,7 @@ class UserZippingTest extends TestCase
|
||||
});
|
||||
|
||||
$this->getJson("/api/zip/folder/$folder->id")
|
||||
->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('zips', [
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
->assertExists(
|
||||
'zip/' . Zip::first()->basename
|
||||
);
|
||||
->assertStatus(200)
|
||||
->assertHeader('content-type', 'application/x-zip');
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,6 +25,6 @@ abstract class TestCase extends BaseTestCase
|
||||
|
||||
resolve(CreateDiskDirectoriesAction::class)();
|
||||
|
||||
//$this->withoutExceptionHandling();
|
||||
$this->withoutExceptionHandling();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user