/** * 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 setAttribute(\Pim\Bundle\CatalogBundle\Model\AttributeInterface $attribute = NULL) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAttribute', array($attribute)); return parent::setAttribute($attribute); }