38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Services\Enhance\EnhanceValidator;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Http\UploadedFile;
|
|
use Illuminate\Validation\ValidationException;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class, RefreshDatabase::class);
|
|
|
|
it('validates a supported uploaded image and normalizes options', function (): void {
|
|
$file = UploadedFile::fake()->image('artwork.png', 1400, 900)->size(768);
|
|
|
|
$validated = app(EnhanceValidator::class)->validateUpload($file, [
|
|
'scale' => 4,
|
|
'mode' => 'illustration',
|
|
'engine' => 'stub',
|
|
]);
|
|
|
|
expect($validated['scale'])->toBe(4);
|
|
expect($validated['mode'])->toBe('illustration');
|
|
expect($validated['engine'])->toBe('stub');
|
|
expect($validated['input_width'])->toBe(1400);
|
|
expect($validated['input_height'])->toBe(900);
|
|
expect($validated['input_mime'])->toBe('image/png');
|
|
});
|
|
|
|
it('rejects unsupported image formats', function (): void {
|
|
$file = UploadedFile::fake()->create('vector.svg', 10, 'image/svg+xml');
|
|
|
|
app(EnhanceValidator::class)->validateUpload($file, [
|
|
'scale' => 2,
|
|
'mode' => 'standard',
|
|
'engine' => 'stub',
|
|
]);
|
|
})->throws(ValidationException::class); |