@@ -95,6 +95,23 @@ public function testGetRemoteTooLarge()
9595 $ this ->assertFalse (is_resource ($ cache ->stream ));
9696 }
9797
98+ public function testGetRemoteExactlyMaxSize ()
99+ {
100+ $ file = new GenericFile ('https://files/image.jpg ' );
101+ $ cache = new FileCacheStub ([
102+ 'path ' => $ this ->cachePath ,
103+ 'max_file_size ' => 3 ,
104+ ]);
105+
106+ $ stream = fopen ('php://temp ' , 'r+ ' );
107+ fwrite ($ stream , 'abc ' );
108+ rewind ($ stream );
109+ $ cache ->stream = $ stream ;
110+ $ path = $ cache ->get ($ file , $ this ->noop );
111+ $ this ->assertEquals (3 , filesize ($ path ));
112+ $ this ->assertFalse (is_resource ($ cache ->stream ));
113+ }
114+
98115 public function testGetDiskDoesNotExist ()
99116 {
100117 $ file = new GenericFile ('abc://files/image.jpg ' );
@@ -180,6 +197,30 @@ public function testGetDiskCloudTooLarge()
180197 $ this ->assertFalse (is_resource ($ stream ));
181198 }
182199
200+ public function testGetDiskCloudExactlyMaxSize ()
201+ {
202+ config (['filesystems.disks.s3 ' => ['driver ' => 's3 ' ]]);
203+ $ file = new GenericFile ('s3://files/image.txt ' );
204+
205+ $ stream = fopen ('php://temp ' , 'r+ ' );
206+ fwrite ($ stream , 'abc ' );
207+ rewind ($ stream );
208+
209+ $ mock = Mockery::mock ();
210+ $ mock ->shouldReceive ('disk ' )->once ()->with ('s3 ' )->andReturn ($ mock );
211+ $ mock ->shouldReceive ('readStream ' )->once ()->andReturn ($ stream );
212+ $ this ->app ['filesystem ' ] = $ mock ;
213+
214+ $ cache = new FileCache ([
215+ 'path ' => $ this ->cachePath ,
216+ 'max_file_size ' => 3 ,
217+ ]);
218+
219+ $ path = $ cache ->get ($ file , $ this ->noop );
220+ $ this ->assertEquals (3 , filesize ($ path ));
221+ $ this ->assertFalse (is_resource ($ stream ));
222+ }
223+
183224 public function testGetThrowOnLock ()
184225 {
185226 $ cache = new FileCache (['path ' => $ this ->cachePath ]);
0 commit comments