|
15 | 15 | $file = UploadedFile::fake()->image('test.jpg', 600, 600); |
16 | 16 | $file->storeAs('/files', 'test.jpg', ['disk' => 'local']); |
17 | 17 |
|
18 | | - $response = $this |
| 18 | + $this |
19 | 19 | ->get( |
20 | 20 | route('code16.sharp.download.show', [ |
21 | 21 | 'entityKey' => 'person', |
|
24 | 24 | 'path' => '/files/test.jpg', |
25 | 25 | ]), |
26 | 26 | ) |
27 | | - ->assertOk(); |
28 | | - |
29 | | - expect($response->content()) |
30 | | - ->toEqual(Storage::disk('local')->get('files/test.jpg')); |
| 27 | + ->assertOk() |
| 28 | + ->assertStreamedContent(Storage::disk('local')->get('files/test.jpg')) |
| 29 | + ->assertHeader('Content-Disposition', 'attachment; filename=test.jpg'); |
31 | 30 | }); |
32 | 31 |
|
33 | 32 | it('allows to download a file from a show field', function () { |
34 | 33 | $file = UploadedFile::fake()->image('test.jpg', 600, 600); |
35 | 34 | $file->storeAs('/files', 'test.jpg', ['disk' => 'local']); |
36 | 35 |
|
37 | | - $response = $this |
| 36 | + $this |
38 | 37 | ->get( |
39 | 38 | route('code16.sharp.download.show', [ |
40 | 39 | 'entityKey' => 'person', |
|
43 | 42 | 'path' => '/files/test.jpg', |
44 | 43 | ]), |
45 | 44 | ) |
46 | | - ->assertOk(); |
47 | | - |
48 | | - expect($response->content()) |
49 | | - ->toEqual(Storage::disk('local')->get('files/test.jpg')); |
| 45 | + ->assertOk() |
| 46 | + ->assertStreamedContent(Storage::disk('local')->get('files/test.jpg')) |
| 47 | + ->assertHeader('Content-Disposition', 'attachment; filename=test.jpg'); |
50 | 48 | }); |
51 | 49 |
|
52 | 50 | it('returns a 404 for a missing file', function () { |
|
55 | 53 | route('code16.sharp.download.show', [ |
56 | 54 | 'entityKey' => 'person', |
57 | 55 | 'instanceId' => 1, |
58 | | - 'fileName' => 'test.jpg', |
| 56 | + 'path' => '/files/unknown.jpg', |
59 | 57 | ]), |
60 | 58 | ) |
61 | 59 | ->assertNotFound(); |
|
0 commit comments