mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-06 02:33:48 +00:00
user zipping
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Zip;
|
||||
|
||||
use Storage;
|
||||
@@ -21,6 +22,24 @@ class UserZippingTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) use ($folder) {
|
||||
$file = UploadedFile::fake()
|
||||
->create("fake-inner-file-$index.pdf", 1200, 'application/pdf');
|
||||
|
||||
$this->postJson('/api/upload', [
|
||||
'filename' => $file->name,
|
||||
'file' => $file,
|
||||
'folder_id' => $folder->id,
|
||||
'is_last' => 'true',
|
||||
])->assertStatus(201);
|
||||
});
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) {
|
||||
$file = UploadedFile::fake()
|
||||
@@ -34,12 +53,13 @@ class UserZippingTest extends TestCase
|
||||
])->assertStatus(201);
|
||||
});
|
||||
|
||||
$file_ids = File::all()->pluck('id')->toArray();
|
||||
|
||||
$ids = implode(',', $file_ids);
|
||||
$files = File::all()
|
||||
->where('folder_id', null)
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
|
||||
$this
|
||||
->getJson("/api/zip/files?ids=$ids")
|
||||
->getJson("/api/zip?items=$files[0]|file,$files[1]|file,$folder->id|folder")
|
||||
->assertStatus(200)
|
||||
->assertHeader('content-type', 'application/x-zip');
|
||||
}
|
||||
@@ -72,7 +92,7 @@ class UserZippingTest extends TestCase
|
||||
])->assertStatus(201);
|
||||
});
|
||||
|
||||
$this->getJson("/api/zip/folder/$folder->id")
|
||||
$this->getJson("/api/zip?items=$folder->id|folder")
|
||||
->assertStatus(200)
|
||||
->assertHeader('content-type', 'application/x-zip');
|
||||
}
|
||||
|
||||
@@ -25,6 +25,6 @@ abstract class TestCase extends BaseTestCase
|
||||
|
||||
resolve(CreateDiskDirectoriesAction::class)();
|
||||
|
||||
$this->withoutExceptionHandling();
|
||||
//$this->withoutExceptionHandling();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user