public function testToArrayWithImageUriAddedOnConstructor() { $element = new ImageUri('http://host.com/img1.jpg'); $collection = new ImageUriCollection(); $collection->add($element); $image = new ProductImage('MOB12345', $collection); $expected = ['SellerSku' => 'MOB12345', 'Images' => ['http://host.com/img1.jpg']]; $this->assertEquals($expected, $image->toArray()); }
public function testSerialization() { $collection = new ImageUriCollection(); $collection->add(new ImageUri('http://host.com/img1.jpg')); $collection->add(new ImageUri('http://host.com/img2.jpg')); \SellerCenter\SDK\Common\AnnotationRegistry::registerAutoloadNamespace(); $serializer = \JMS\Serializer\SerializerBuilder::create()->build(); $xml = ' <Images> <Image>http://host.com/img1.jpg</Image> <Image>http://host.com/img2.jpg</Image> </Images> '; $this->assertXmlStringEqualsXmlString($xml, $serializer->serialize($collection, 'xml')); }
/** * @JMS\VirtualProperty * @JMS\SerializedName("Images") * @JMS\XmlList(inline = false, entry = "Image") */ public function getElements() { return parent::getElements(); }