/** * Test getter/setter for data property */ public function testGetSetData() { $expectedData = 'test-data'; $this->assertNull($this->price->getData()); $this->assertEntity($this->price->setData($expectedData)); $this->assertEquals($expectedData, $this->price->getData()); }
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 setData($data) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setData', array($data)); return parent::setData($data); }
/** * 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)); }