@@ -125,7 +125,8 @@ public function testDirectoryExists()
125125 $ this ->container ->shouldReceive ('listObjects ' )
126126 ->once ()
127127 ->with ([
128- 'prefix ' => 'hello ' ,
128+ 'prefix ' => 'hello/ ' ,
129+ 'delimiter ' => '/ ' ,
129130 ])
130131 ->andReturn ($ objects );
131132
@@ -138,7 +139,8 @@ public function testDirectoryExists()
138139 $ this ->container ->shouldReceive ('listObjects ' )
139140 ->once ()
140141 ->with ([
141- 'prefix ' => 'world ' ,
142+ 'prefix ' => 'world/ ' ,
143+ 'delimiter ' => '/ ' ,
142144 ])
143145 ->andReturn ($ objects );
144146
@@ -161,7 +163,8 @@ public function testListContents()
161163 $ this ->container ->shouldReceive ('listObjects ' )
162164 ->once ()
163165 ->with ([
164- 'prefix ' => 'hello ' ,
166+ 'prefix ' => 'hello/ ' ,
167+ 'delimiter ' => '/ ' ,
165168 ])
166169 ->andReturn ($ objects );
167170
@@ -172,9 +175,7 @@ public function testListContents()
172175 'mime_type ' => 'text/html; charset=UTF-8 ' ,
173176 'visibility ' => null ,
174177 'file_size ' => 0 ,
175- 'extra_metadata ' => [
176- 'type ' => 'file ' ,
177- ],
178+ 'extra_metadata ' => [],
178179 ];
179180
180181 $ contents = $ this ->adapter ->listContents ('hello ' , false );
@@ -188,6 +189,34 @@ public function testListContents()
188189 $ this ->assertEquals ($ times , $ count );
189190 }
190191
192+ public function testListContentsPseudoDirectory ()
193+ {
194+ $ object = Mockery::mock (StorageObject::class);
195+ $ object ->name = 'name/ ' ;
196+ $ generator = function () use ($ object ) {
197+ yield $ object ;
198+ };
199+ $ objects = $ generator ();
200+ $ this ->container ->shouldReceive ('listObjects ' )
201+ ->once ()
202+ ->with ([
203+ 'prefix ' => 'hello/ ' ,
204+ 'delimiter ' => '/ ' ,
205+ ])
206+ ->andReturn ($ objects );
207+
208+ $ expect = [
209+ 'path ' => 'name ' ,
210+ 'type ' => 'dir ' ,
211+ 'visibility ' => null ,
212+ 'extra_metadata ' => [],
213+ 'last_modified ' => null ,
214+ ];
215+
216+ $ contents = iterator_to_array ($ this ->adapter ->listContents ('hello ' , false ));
217+ $ this ->assertEquals ($ expect , $ contents [0 ]->jsonSerialize ());
218+ }
219+
191220 public function testMove ()
192221 {
193222 $ this ->object ->shouldReceive ('copy ' )->once ()->with ([
@@ -358,9 +387,7 @@ public function testMetadataMethods()
358387 'mime_type ' => 'text/html; charset=UTF-8 ' ,
359388 'visibility ' => null ,
360389 'file_size ' => 0 ,
361- 'extra_metadata ' => [
362- 'type ' => 'file ' ,
363- ],
390+ 'extra_metadata ' => [],
364391 ];
365392
366393 foreach ($ methods as $ method ) {
0 commit comments