/** * Test getter/setter for currency property */ public function testGetSetCurrency() { $expectedCurrency = 'test-currency'; $this->assertNull($this->price->getCurrency()); $this->assertEntity($this->price->setCurrency($expectedCurrency)); $this->assertEquals($expectedCurrency, $this->price->getCurrency()); }
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 setCurrency($currency) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCurrency', array($currency)); return parent::setCurrency($currency); }
/** * 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)); }