Ejemplo n.º 1
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 setProducts(array $products)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setProducts', array($products));
     return parent::setProducts($products);
 }