/** * Test related methods */ public function testGuessUpdates() { $attribute = new Attribute(); $attribute->setCode('my_attribute'); $value = new ProductValue(); $value->setAttribute($attribute); $product = new Product(); $product->addValue($value); $guesser = new ProductValueUpdateGuesser(); $em = $this->getEntityManagerMock(); $updates = $guesser->guessUpdates($em, $value, UpdateGuesserInterface::ACTION_UPDATE_ENTITY); $this->assertEquals(1, count($updates)); $this->assertEquals($product, $updates[0]); $attribute = new Attribute(); $attribute->setCode('my_price'); $price = new ProductPrice(); $value = new ProductValue(); $value->setAttribute($attribute); $value->addPrice($price); $product = new Product(); $product->addValue($value); $updates = $guesser->guessUpdates($em, $price, UpdateGuesserInterface::ACTION_UPDATE_ENTITY); $this->assertEquals(1, count($updates)); $this->assertEquals($product, $updates[0]); }
/** * {@inheritDoc} */ public function addPrice(\Pim\Bundle\CatalogBundle\Model\ProductPriceInterface $price) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'addPrice', array($price)); return parent::addPrice($price); }