Skip to content

Commit 4b16345

Browse files
committed
remove support for file uploads as an array in UploadController and related tests
1 parent 730654e commit 4b16345

File tree

2 files changed

+0
-23
lines changed

2 files changed

+0
-23
lines changed

app/Http/Controllers/Admin/UploadController.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ public function __invoke(Request $request): JsonResponse
2929

3030
$file = $request->file('upload');
3131

32-
if (is_array($file)) {
33-
$file = $file[0];
34-
}
35-
3632
if (! $file instanceof UploadedFile) {
3733
return response()->json(['error' => 'Invalid upload'], 400);
3834
}

tests/Feature/App/Http/Controllers/Admin/UploadControllerTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,6 @@
2525
Storage::disk('images')->assertExists($path);
2626
});
2727

28-
test('handles valid upload when file is sent as an array', function () {
29-
$file = UploadedFile::fake()->image('photo.jpg');
30-
31-
$mockRequest = Mockery::mock(Request::class);
32-
$mockRequest->shouldReceive('validate')->andReturn(['upload' => [$file]]);
33-
$mockRequest->shouldReceive('hasFile')->once()->with('upload')->andReturn(true);
34-
$mockRequest->shouldReceive('file')->once()->with('upload')->andReturn([$file]);
35-
36-
$controller = new UploadController;
37-
38-
$response = $controller($mockRequest);
39-
40-
expect($response->getStatusCode())->toBe(200);
41-
expect($response->getData(true))->toHaveKey('url');
42-
43-
$path = str_replace('/images/', '', $response->getData(true)['url']);
44-
Storage::disk('images')->assertExists($path);
45-
});
46-
4728
test('fails when no file is uploaded', function () {
4829
postJson(route('image-upload'), [])->assertStatus(422);
4930
});

0 commit comments

Comments
 (0)