/**
  * Bind products
  *
  * @param Group $group
  * @param array $appendProducts
  * @param array $removeProducts
  */
 protected function bindProducts(Group $group, array $appendProducts, array $removeProducts)
 {
     foreach ($appendProducts as $product) {
         $group->addProduct($product);
     }
     foreach ($removeProducts as $product) {
         $group->removeProduct($product);
     }
 }
Ejemplo n.º 2
0
 /**
  * Test getter/setter/add/remove for products property
  */
 public function testGetSetAddRemoveProducts()
 {
     // Change value and assert new
     $newProduct = new Product();
     $this->assertEntity($this->group->addProduct($newProduct));
     $this->assertInstanceOf('Pim\\Bundle\\CatalogBundle\\Model\\Product', $this->group->getProducts()->first());
     $this->assertEntity($this->group->removeProduct($newProduct));
     $this->assertNotInstanceOf('Pim\\Bundle\\CatalogBundle\\Model\\Product', $this->group->getProducts()->first());
     $this->assertCount(0, $this->group->getProducts());
     // Use setter and assert getProducts result
     $newProduct1 = new Product();
     $expectedProducts = array($newProduct, $newProduct1);
     $this->assertEntity($this->group->setProducts($expectedProducts));
     $this->assertCount(2, $this->group->getProducts());
 }
 /**
  * {@inheritDoc}
  */
 public function addProduct(\Pim\Bundle\CatalogBundle\Model\ProductInterface $product)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'addProduct', array($product));
     return parent::addProduct($product);
 }