@@ -25,6 +25,40 @@ public function it_will_try_to_optimize_all_files_in_a_request()
2525 $ this ->assertDecreasedFileSize ($ uploadPath , $ originalImagePath );
2626 }
2727
28+ /** @test */
29+ public function it_will_optimize_all_files_at_all_depths ()
30+ {
31+ $ originalImagePath1 = $ this ->getImagePath ('logo.png ' );
32+ $ uploadPath1 = $ this ->getTempPath ('logo.png ' );
33+
34+ $ originalImagePath2 = $ this ->getImagePath ('logo2.png ' );
35+ $ uploadPath2 = $ this ->getTempPath ('logo2.png ' );
36+
37+ $ originalImagePath3 = $ this ->getImagePath ('logo3.png ' );
38+ $ uploadPath3 = $ this ->getTempPath ('logo3.png ' );
39+
40+ copy ($ originalImagePath1 , $ uploadPath1 );
41+ copy ($ originalImagePath2 , $ uploadPath2 );
42+ copy ($ originalImagePath3 , $ uploadPath3 );
43+
44+ Route::middleware (OptimizeImages::class)->post ('/ ' , function () {
45+ });
46+
47+ $ this ->call ('POST ' , '/ ' , [], [], [
48+ 'upload ' => $ this ->getUploadFile ($ uploadPath1 ),
49+ 'one ' => [
50+ 'two ' => $ this ->getUploadFile ($ uploadPath2 ),
51+ 'three ' => [
52+ 'four ' => $ this ->getUploadFile ($ uploadPath3 ),
53+ ],
54+ ],
55+ ]);
56+
57+ $ this ->assertDecreasedFileSize ($ uploadPath1 , $ originalImagePath1 );
58+ $ this ->assertDecreasedFileSize ($ uploadPath2 , $ originalImagePath2 );
59+ $ this ->assertDecreasedFileSize ($ uploadPath3 , $ originalImagePath3 );
60+ }
61+
2862 protected function getUploadFile (string $ path ): UploadedFile
2963 {
3064 return new UploadedFile (
0 commit comments