<?php
declare(strict_types=1);
namespace Tests\Unit\Jobs;
use App\Jobs\ProcessMedia;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\ImageManager;
use Tests\TestCase;
class ProcessMediaJobTest extends TestCase
{
/** @test */
public function nonMediaFilesAreNotSaved(): void
Storage::fake('s3');
$manager = app()->make(ImageManager::class);
Storage::disk('local')->put('file.txt', 'This is not an image');
$job = new ProcessMedia('file.txt');
$job->handle($manager);
$this->assertFalse(file_exists(storage_path('app') . '/file.txt'));
}
public function smallImagesAreNotResized(): void
Storage::disk('local')->put('aaron.png', file_get_contents(__DIR__ . '/../../aaron.png'));
$job = new ProcessMedia('aaron.png');
$this->assertFalse(file_exists(storage_path('app') . '/aaron.png'));
public function largeImagesHaveSmallerImagesCreated(): void
Storage::disk('local')->put('test-image.jpg', file_get_contents(__DIR__.'/../../test-image.jpg'));
$job = new ProcessMedia('test-image.jpg');
Storage::disk('s3')->assertExists('media/test-image-small.jpg');
Storage::disk('s3')->assertExists('media/test-image-medium.jpg');
$this->assertFalse(file_exists(storage_path('app') . '/test-image.jpg'));