mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
remote upload backend functionality
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Files;
|
||||
|
||||
use Storage;
|
||||
@@ -9,6 +10,7 @@ use Domain\Files\Models\File;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class FileTest extends TestCase
|
||||
{
|
||||
@@ -59,7 +61,7 @@ class FileTest extends TestCase
|
||||
])
|
||||
->collapse()
|
||||
->each(
|
||||
fn ($item) => Storage::assertExists(
|
||||
fn($item) => Storage::assertExists(
|
||||
"files/{$user->id}/{$item['name']}-{$file->basename}"
|
||||
)
|
||||
);
|
||||
@@ -100,6 +102,54 @@ class FileTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_remotely_upload_new_file()
|
||||
{
|
||||
$user = User::factory()
|
||||
->hasSettings()
|
||||
->create();
|
||||
|
||||
$folder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$fakeFile = UploadedFile::fake()
|
||||
->create('top-secret-document.pdf', 12000000, 'application/pdf');
|
||||
|
||||
Http::fake([
|
||||
'https://fake.com/top-secret-document.pdf' => Http::response($fakeFile->getContent()),
|
||||
'https://fake.com/another-secret-document.pdf' => Http::response($fakeFile->getContent()),
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/upload/remote', [
|
||||
'urls' => [
|
||||
'https://fake.com/top-secret-document.pdf',
|
||||
'https://fake.com/another-secret-document.pdf',
|
||||
],
|
||||
'parent_id' => $folder->id,
|
||||
])->assertStatus(201);
|
||||
|
||||
$this
|
||||
->assertDatabaseHas('files', [
|
||||
'user_id' => $user->id,
|
||||
'name' => 'top-secret-document',
|
||||
'parent_id' => $folder->id,
|
||||
])
|
||||
->assertDatabaseHas('files', [
|
||||
'name' => 'another-secret-document',
|
||||
]);
|
||||
|
||||
File::all()
|
||||
->each(function ($file) {
|
||||
Storage::assertExists("files/$file->user_id/$file->basename");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
@@ -233,7 +283,7 @@ class FileTest extends TestCase
|
||||
'parent_id' => $folder->id,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
@@ -288,7 +338,7 @@ class FileTest extends TestCase
|
||||
|
||||
// Assert thumbnail was deleted
|
||||
getThumbnailFileList('fake-image.jpeg')
|
||||
->each(fn ($thumbnail) => Storage::assertMissing("files/$user->id/$thumbnail"));
|
||||
->each(fn($thumbnail) => Storage::assertMissing("files/$user->id/$thumbnail"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,8 +437,8 @@ class FileTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
* @test
|
||||
*/
|
||||
public function it_store_file_exif_data_after_file_upload()
|
||||
{
|
||||
$file = UploadedFile::fake()
|
||||
|
||||
Reference in New Issue
Block a user