File tree Expand file tree Collapse file tree 2 files changed +0
-23
lines changed
app/Http/Controllers/Admin
tests/Feature/App/Http/Controllers/Admin Expand file tree Collapse file tree 2 files changed +0
-23
lines changed Original file line number Diff line number Diff line change @@ -29,10 +29,6 @@ public function __invoke(Request $request): JsonResponse
29
29
30
30
$ file = $ request ->file ('upload ' );
31
31
32
- if (is_array ($ file )) {
33
- $ file = $ file [0 ];
34
- }
35
-
36
32
if (! $ file instanceof UploadedFile) {
37
33
return response ()->json (['error ' => 'Invalid upload ' ], 400 );
38
34
}
Original file line number Diff line number Diff line change 25
25
Storage::disk ('images ' )->assertExists ($ path );
26
26
});
27
27
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
-
47
28
test ('fails when no file is uploaded ' , function () {
48
29
postJson (route ('image-upload ' ), [])->assertStatus (422 );
49
30
});
You can’t perform that action at this time.
0 commit comments