Implement creator studio and upload updates
This commit is contained in:
30
tests/Unit/Upload/PreviewServiceTest.php
Normal file
30
tests/Unit/Upload/PreviewServiceTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Services\Upload\PreviewService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
|
||||
uses(TestCase::class, RefreshDatabase::class);
|
||||
|
||||
it('generates a smart square thumb during preview creation', function () {
|
||||
Storage::fake('local');
|
||||
|
||||
$uploadId = (string) Str::uuid();
|
||||
$file = UploadedFile::fake()->image('preview-source.jpg', 1200, 800);
|
||||
$path = $file->storeAs("tmp/drafts/{$uploadId}/main", 'preview-source.jpg', 'local');
|
||||
|
||||
$result = app(PreviewService::class)->generateFromImage($uploadId, $path);
|
||||
|
||||
expect(Storage::disk('local')->exists($result['preview_path']))->toBeTrue()
|
||||
->and(Storage::disk('local')->exists($result['thumb_path']))->toBeTrue();
|
||||
|
||||
$thumbSize = getimagesizefromstring(Storage::disk('local')->get($result['thumb_path']));
|
||||
|
||||
expect($thumbSize[0] ?? null)->toBe(320)
|
||||
->and($thumbSize[1] ?? null)->toBe(320);
|
||||
});
|
||||
Reference in New Issue
Block a user