@@ -116,7 +116,8 @@ public function test_It_Create_Objects()
116116
117117 $ this ->setupMock ('PUT ' , self ::NAME . '/ ' . $ objectName , $ content , $ headers , 'Created ' );
118118
119- $ this ->container ->createObject ([
119+ /** @var StorageObject $storageObject */
120+ $ storageObject = $ this ->container ->createObject ([
120121 'name ' => $ objectName ,
121122 'content ' => $ content ,
122123 'contentType ' => $ headers ['Content-Type ' ],
@@ -125,6 +126,9 @@ public function test_It_Create_Objects()
125126 'deleteAfter ' => $ headers ['X-Delete-After ' ],
126127 'metadata ' => ['Author ' => 'foo ' , 'genre ' => 'bar ' ],
127128 ]);
129+
130+ $ this ->assertEquals ('foo.txt ' , $ storageObject ->name );
131+ $ this ->assertEquals (self ::NAME , $ storageObject ->containerName );
128132 }
129133
130134 public function test_it_lists_objects ()
@@ -134,8 +138,37 @@ public function test_it_lists_objects()
134138 ->shouldBeCalled ()
135139 ->willReturn ($ this ->getFixture ('GET_Container ' ));
136140
137- foreach ($ this ->container ->listObjects (['limit ' => 2 ]) as $ object ) {
138- $ this ->assertInstanceOf (StorageObject::class, $ object );
141+ $ objects = iterator_to_array ($ this ->container ->listObjects (['limit ' => 2 ]));
142+
143+ $ this ->assertEquals (2 , count ($ objects ));
144+
145+ $ expected = [
146+ [
147+ 'name ' => 'goodbye ' ,
148+ 'contentLength ' => '14 ' ,
149+ 'lastModified ' => new \DateTimeImmutable ('2014-01-15T16:41:49.390270 ' ),
150+ 'contentType ' => 'application/octet-stream ' ,
151+ 'hash ' => '451e372e48e0f6b1114fa0724aa79fa1 '
152+ ],
153+ [
154+ 'name ' => 'helloworld.json ' ,
155+ 'contentLength ' => '12 ' ,
156+ 'lastModified ' => new \DateTimeImmutable ('2014-01-15T16:37:43.427570 ' ),
157+ 'contentType ' => 'application/json ' ,
158+ 'hash ' => 'ed076287532e86365e841e92bfc50d8c '
159+ ],
160+ ];
161+
162+ for ($ i = 0 ; $ i < count ($ objects ); $ i ++)
163+ {
164+ $ exp = $ expected [$ i ];
165+ /** @var StorageObject $obj */
166+ $ obj = $ objects [$ i ];
167+
168+ foreach ($ exp as $ attr => $ attrVal )
169+ {
170+ $ this ->assertEquals ($ attrVal , $ obj ->{$ attr });
171+ }
139172 }
140173 }
141174
0 commit comments