@@ -174,7 +174,7 @@ public function testConvertToYotiAttributeMultiValue()
174
174
$ multiValue = $ attr ->getValue ();
175
175
176
176
// Check top-level items.
177
- $ this ->assertEquals (4 , count ($ multiValue ));
177
+ $ this ->assertEquals (count ( $ values ) , count ($ multiValue ));
178
178
$ this ->assertInstanceOf (MultiValue::class, $ multiValue );
179
179
180
180
$ this ->assertInstanceOf (Image::class, $ multiValue [0 ]);
@@ -187,21 +187,22 @@ public function testConvertToYotiAttributeMultiValue()
187
187
188
188
$ this ->assertEquals ('test string ' , $ multiValue [2 ]);
189
189
190
- $ this ->assertInstanceOf (MultiValue::class, $ multiValue [3 ]);
190
+ $ this ->assertNull ($ multiValue [3 ]);
191
+
192
+ $ this ->assertInstanceOf (MultiValue::class, $ multiValue [4 ]);
191
193
192
194
// Check nested items.
193
- $ this ->assertEquals (3 , count ($ multiValue [3 ]));
194
- $ this ->assertInstanceOf (MultiValue::class, $ multiValue [3 ]);
195
+ $ this ->assertEquals (4 , count ($ multiValue [4 ]));
195
196
196
- $ this ->assertInstanceOf (Image::class, $ multiValue [3 ][0 ]);
197
- $ this ->assertEquals ('image/jpeg ' , $ multiValue [3 ][0 ]->getMimeType ());
198
- $ this ->assertNotEmpty ($ multiValue [3 ][0 ]->getContent ());
197
+ $ this ->assertInstanceOf (Image::class, $ multiValue [4 ][0 ]);
198
+ $ this ->assertEquals ('image/jpeg ' , $ multiValue [4 ][0 ]->getMimeType ());
199
+ $ this ->assertNotEmpty ($ multiValue [4 ][0 ]->getContent ());
199
200
200
- $ this ->assertInstanceOf (Image::class, $ multiValue [3 ][1 ]);
201
- $ this ->assertEquals ('image/png ' , $ multiValue [3 ][1 ]->getMimeType ());
202
- $ this ->assertNotEmpty ($ multiValue [3 ][1 ]->getContent ());
201
+ $ this ->assertInstanceOf (Image::class, $ multiValue [4 ][1 ]);
202
+ $ this ->assertEquals ('image/png ' , $ multiValue [4 ][1 ]->getMimeType ());
203
+ $ this ->assertNotEmpty ($ multiValue [4 ][1 ]->getContent ());
203
204
204
- $ this ->assertEquals ('test string ' , $ multiValue [3 ][2 ]);
205
+ $ this ->assertEquals ('test string ' , $ multiValue [4 ][2 ]);
205
206
}
206
207
207
208
/**
@@ -226,24 +227,21 @@ private function createTestNestedMultiValueItem()
226
227
*/
227
228
private function createTestMultiValueItems ()
228
229
{
230
+ $ createValues = [
231
+ ['image 1 ' , self ::CONTENT_TYPE_JPEG ],
232
+ ['image 2 ' , self ::CONTENT_TYPE_PNG ],
233
+ ['test string ' , self ::CONTENT_TYPE_STRING ],
234
+ ['' , self ::CONTENT_TYPE_STRING ],
235
+ ];
236
+
229
237
$ values = [];
230
238
231
- // Add images.
232
- $ protoMultiValueValue = new \Attrpubapi \MultiValue \Value ();
233
- $ protoMultiValueValue ->setData ('image 1 ' );
234
- $ protoMultiValueValue ->setContentType (self ::CONTENT_TYPE_JPEG );
235
- $ values [] = $ protoMultiValueValue ;
236
-
237
- $ protoMultiValueValue = new \Attrpubapi \MultiValue \Value ();
238
- $ protoMultiValueValue ->setData ('image 2 ' );
239
- $ protoMultiValueValue ->setContentType (self ::CONTENT_TYPE_PNG );
240
- $ values [] = $ protoMultiValueValue ;
241
-
242
- // Add string.
243
- $ protoMultiValueValue = new \Attrpubapi \MultiValue \Value ();
244
- $ protoMultiValueValue ->setData ('test string ' );
245
- $ protoMultiValueValue ->setContentType (self ::CONTENT_TYPE_STRING );
246
- $ values [] = $ protoMultiValueValue ;
239
+ foreach ($ createValues as $ createValue ) {
240
+ $ protoMultiValueValue = new \Attrpubapi \MultiValue \Value ();
241
+ $ protoMultiValueValue ->setData ($ createValue [0 ]);
242
+ $ protoMultiValueValue ->setContentType ($ createValue [1 ]);
243
+ $ values [] = $ protoMultiValueValue ;
244
+ }
247
245
248
246
return $ values ;
249
247
}
0 commit comments