32 lines
819 B
PHP
32 lines
819 B
PHP
<?php
|
|
namespace App\Domains\File\Tests\Services;
|
|
|
|
use App\Core\TestCase;
|
|
use Illuminate\Http\UploadedFile;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use App\Domains\File\Services\FileService;
|
|
|
|
class FileServiceTest extends TestCase
|
|
{
|
|
public function testFileService()
|
|
{
|
|
$fileService = app(FileService::class);
|
|
|
|
$file = UploadedFile::fake()->image('avatar.jpg', $width = 256, $height = 256)->size(100);
|
|
|
|
$fileModel = $fileService->upload($file, [
|
|
'filename' => 'account/avatar/1.jpg',
|
|
'type' => 'account/avatar',
|
|
'typeid' => 1,
|
|
], $disk = 'data');
|
|
|
|
$disk = Storage::disk($disk);
|
|
|
|
$disk->assertExists($fileModel->filename);
|
|
|
|
$disk->delete($fileModel->filename);
|
|
|
|
$disk->assertMissing($fileModel->filename);
|
|
}
|
|
}
|