Exemplo n.º 1
0
 public function testSetBody()
 {
     $element = new Product();
     $element->setSellerSku('ASM_A8012');
     $collection = new ProductCollection();
     $collection->add($element);
     $body = new Body();
     $body->setProducts($collection);
     $response = new Response();
     $response->setBody($body);
     $this->assertEquals('ASM_A8012', $response->getBody()->getProducts()->first()->getSellerSku());
 }
 public function testSerialization()
 {
     $element1 = new Product();
     $element1->setSellerSku('MOB_12543');
     $element2 = new Product();
     $element2->setSellerSku('ASM_A8012');
     $collection = new ProductCollection();
     $collection->add($element1);
     $collection->add($element2);
     \SellerCenter\SDK\Common\AnnotationRegistry::registerAutoloadNamespace();
     $serializer = \JMS\Serializer\SerializerBuilder::create()->build();
     $xml = '
         <Request>
             <Product>
                 <SellerSku>MOB_12543</SellerSku>
             </Product>
             <Product>
                 <SellerSku>ASM_A8012</SellerSku>
             </Product>
         </Request>
     ';
     $this->assertXmlStringEqualsXmlString($xml, $serializer->serialize($collection, 'xml'));
 }
Exemplo n.º 3
0
 /**
  * @return array
  */
 public function toArray()
 {
     return $this->products->toArray();
 }