function it_normalizes_a_price_into_mongodb_document($mongoFactory, ProductPrice $price, \MongoId $mongoId)
 {
     $mongoFactory->createMongoId()->willReturn($mongoId);
     $price->getCurrency()->willReturn('USD');
     $price->getData()->willReturn(9.99);
     $this->normalize($price, 'mongodb_document')->shouldReturn(['_id' => $mongoId, 'currency' => 'USD', 'data' => 9.99]);
 }
 /**
  * Test getter/setter for value property
  */
 public function testGetSetValue()
 {
     $value = new ProductValue();
     $this->assertNull($this->price->getValue());
     $this->assertEntity($this->price->setValue($value));
     $this->assertInstanceOf('Pim\\Bundle\\CatalogBundle\\Model\\ProductValue', $this->price->getValue());
 }
 function it_normalizes_value_with_collection_data(SerializerInterface $serializer, ProductValueInterface $value, AbstractAttribute $attribute)
 {
     $serializer->implement('Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface');
     $this->setSerializer($serializer);
     $attribute->getCode()->willReturn('code');
     $attribute->isLocalizable()->willReturn(false);
     $attribute->isScopable()->willReturn(false);
     $price = new ProductPrice();
     $price->setData(42);
     $price->setCurrency('EUR');
     $collection = new ArrayCollection([$price]);
     $value->getData()->willReturn($collection);
     $value->getAttribute()->willReturn($attribute);
     $serializer->normalize($price, 'mongodb_json', [])->willReturn(['data' => 42, 'currency' => 'EUR']);
     $this->normalize($value, 'mongodb_json', [])->shouldReturn(['code' => ['EUR' => ['data' => 42, 'currency' => 'EUR']]]);
 }
 /**
  * {@inheritDoc}
  */
 public function __toString()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, '__toString', array());
     return parent::__toString();
 }
 function it_normalizes_a_collection_of_product_prices($value, $attribute, ProductPrice $price1, ProductPrice $price2)
 {
     $attribute->isScopable()->willReturn(true);
     $attribute->isLocalizable()->willReturn(false);
     $value->getData()->willReturn([$price1, $price2]);
     $price1->getData()->willReturn('10.0');
     $price1->getCurrency()->willReturn('EUR');
     $price2->getData()->willReturn('12.0');
     $price2->getCurrency()->willReturn('currency_code');
     $this->normalize($value, 'MagentoArray', $this->globalContext)->shouldReturn(['attribute_code' => '12.0']);
 }
 /**
  * Data provider for wrong simple data
  *
  * @return array
  */
 public static function dataProviderWithWrongSimpleData()
 {
     $attribute = new Attribute();
     $attribute->setCode('price');
     $attribute->setAttributeType('pim_catalog_price_collection')->setBackendType('prices');
     $price = new ProductPrice();
     $price->setCurrency('EUR');
     $price->setData(null);
     return array(array('null' => null), array('empty string' => ''), array('empty option collection' => new ArrayCollection()), array('unexpected price collection' => new ArrayCollection(array($price)), $attribute));
 }