function it_denormalizes_association_with_products(Association $association, Serializer $serializer, ProductInterface $product1, ProductInterface $product2) { // Mock product denormalization $serializer->denormalize('foo', self::PRODUCT_CLASS, self::FORMAT_CSV)->willReturn($product1); $serializer->denormalize('bar', self::PRODUCT_CLASS, self::FORMAT_CSV)->willReturn($product2); $association->addProduct($product1)->shouldBeCalled(); $association->addProduct($product2)->shouldBeCalled(); $this->setSerializer($serializer); $this->denormalize('foo,bar', self::ENTITY_CLASS, self::FORMAT_CSV, ['part' => 'products', 'entity' => $association]); }
/** * {@inheritDoc} */ public function addProduct(\Pim\Bundle\CatalogBundle\Model\ProductInterface $product) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'addProduct', array($product)); return parent::addProduct($product); }