@@ -191,10 +191,9 @@ public function testListContents()
191191
192192 public function testListContentsPseudoDirectory ()
193193 {
194- $ object = Mockery::mock (StorageObject::class);
195- $ object ->name = 'name/ ' ;
196- $ generator = function () use ($ object ) {
197- yield $ object ;
194+ $ this ->object ->name = 'name/ ' ;
195+ $ generator = function () {
196+ yield $ this ->object ;
198197 };
199198 $ objects = $ generator ();
200199 $ this ->container ->shouldReceive ('listObjects ' )
@@ -217,6 +216,79 @@ public function testListContentsPseudoDirectory()
217216 $ this ->assertEquals ($ expect , $ contents [0 ]->jsonSerialize ());
218217 }
219218
219+ public function testListContentsDeep ()
220+ {
221+ $ times = mt_rand (1 , 10 );
222+
223+ $ generator = function () {
224+ yield $ this ->object ;
225+ };
226+
227+ $ objects = $ generator ();
228+
229+ $ this ->container ->shouldReceive ('listObjects ' )
230+ ->once ()
231+ ->with ([
232+ 'prefix ' => 'hello/ ' ,
233+ ])
234+ ->andReturn ($ objects );
235+
236+ $ expect = [
237+ 'path ' => 'name ' ,
238+ 'type ' => 'file ' ,
239+ 'last_modified ' => 1628624822 ,
240+ 'mime_type ' => 'text/html; charset=UTF-8 ' ,
241+ 'visibility ' => null ,
242+ 'file_size ' => 0 ,
243+ 'extra_metadata ' => [],
244+ ];
245+
246+ $ contents = $ this ->adapter ->listContents ('hello ' , true );
247+
248+ foreach ($ contents as $ file ) {
249+ $ this ->assertEquals ($ expect , $ file ->jsonSerialize ());
250+ }
251+ }
252+
253+ public function testListContentsPseudoDirectoryDeep ()
254+ {
255+ $ this ->object ->name = 'pseudo/directory/name ' ;
256+ $ generator = function () {
257+ yield $ this ->object ;
258+ };
259+ $ objects = $ generator ();
260+ $ this ->container ->shouldReceive ('listObjects ' )
261+ ->once ()
262+ ->with ([
263+ 'prefix ' => 'pseudo/ ' ,
264+ ])
265+ ->andReturn ($ objects );
266+
267+ $ expect = [
268+ [
269+ 'path ' => 'pseudo/directory ' ,
270+ 'type ' => 'dir ' ,
271+ 'visibility ' => null ,
272+ 'extra_metadata ' => [],
273+ 'last_modified ' => null ,
274+ ],
275+ [
276+ 'path ' => 'pseudo/directory/name ' ,
277+ 'type ' => 'file ' ,
278+ 'last_modified ' => 1628624822 ,
279+ 'mime_type ' => 'text/html; charset=UTF-8 ' ,
280+ 'visibility ' => null ,
281+ 'file_size ' => 0 ,
282+ 'extra_metadata ' => [],
283+ ],
284+ ];
285+
286+ $ contents = $ this ->adapter ->listContents ('pseudo ' , true );
287+ foreach ($ contents as $ index => $ value ) {
288+ $ this ->assertEquals ($ expect [$ index ], $ value ->jsonSerialize ());
289+ }
290+ }
291+
220292 public function testMove ()
221293 {
222294 $ this ->object ->shouldReceive ('copy ' )->once ()->with ([
0 commit comments