function it_removes_an_attribute_group($repository, $objectManager, AttributeGroup $default, AttributeGroup $group, AbstractAttribute $attribute)
 {
     $repository->findDefaultAttributeGroup()->willReturn($default);
     $group->removeAttribute($attribute)->shouldBeCalled();
     $attribute->setGroup($default)->shouldBeCalled();
     $objectManager->persist($group)->shouldBeCalled();
     $objectManager->persist($attribute)->shouldBeCalled();
     $objectManager->flush()->shouldBeCalled();
     $this->removeAttribute($group, $attribute);
 }
 /**
  * Remove an attribute from a group and link it to the default group
  *
  * @param AttributeGroup    $group
  * @param AbstractAttribute $attribute
  *
  * @throws \LogicException
  *
  * @return AbstractAttribute
  */
 public function removeAttribute(AttributeGroup $group, AbstractAttribute $attribute)
 {
     if (null === ($default = $this->repository->findDefaultAttributeGroup())) {
         throw new \LogicException('The default attribute group should exist.');
     }
     $group->removeAttribute($attribute);
     $attribute->setGroup($default);
     $this->objectManager->persist($group);
     $this->objectManager->persist($attribute);
     $this->objectManager->flush();
 }
 /**
  * Test getter/setter for attributes property
  */
 public function testAttributes()
 {
     $this->assertCount(0, $this->group->getAttributes());
     // Change value and assert new
     $newAttribute = new Attribute();
     $this->assertEntity($this->group->addAttribute($newAttribute));
     $this->assertCount(1, $this->group->getAttributes());
     $this->assertInstanceOf('Pim\\Bundle\\CatalogBundle\\Entity\\Attribute', $this->group->getAttributes()->first());
     $this->assertTrue($this->group->hasAttribute($newAttribute));
     $this->assertEntity($this->group->removeAttribute($newAttribute));
     $this->assertCount(0, $this->group->getAttributes());
 }
 /**
  * {@inheritDoc}
  */
 public function removeAttribute(\Pim\Bundle\CatalogBundle\Model\AttributeInterface $attribute)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeAttribute', array($attribute));
     return parent::removeAttribute($attribute);
 }