function it_denormalizes_an_existing_group_with_properties($groupRepository, Group $group, GroupType $type, AttributeInterface $size, AttributeInterface $color, GroupTranslation $translationUS)
 {
     $groupRepository->findOneByIdentifier('tshirt')->willReturn(null);
     $group->getId()->willReturn(42);
     $group->setCode('tshirt')->shouldBeCalled();
     $group->setType(Argument::any())->shouldNotBeCalled();
     $group->setAttributes(Argument::any())->shouldNotBeCalled();
     $group->getTranslation('en_US')->willReturn($translationUS);
     $translationUS->setLabel('My T-shirt')->shouldBeCalled();
     $group->addTranslation($translationUS)->shouldBeCalled();
     $this->denormalize(['code' => 'tshirt', 'label-en_US' => 'My T-shirt'], self::ENTITY_CLASS, self::FORMAT_CSV, ['entity' => $group])->shouldReturn($group);
 }
 /**
  * Test getter/setter for translations property
  */
 public function testTranslations()
 {
     $this->assertCount(0, $this->group->getTranslations());
     // Change value and assert new
     $newTranslation = new GroupTranslation();
     $this->assertEntity($this->group->addTranslation($newTranslation));
     $this->assertCount(1, $this->group->getTranslations());
     $this->assertInstanceOf('Pim\\Bundle\\CatalogBundle\\Entity\\GroupTranslation', $this->group->getTranslations()->first());
     $this->group->addTranslation($newTranslation);
     $this->assertCount(1, $this->group->getTranslations());
     $this->assertEntity($this->group->removeTranslation($newTranslation));
     $this->assertCount(0, $this->group->getTranslations());
 }
 /**
  * {@inheritdoc}
  *
  * @return Group
  */
 protected function createEntity(array $data)
 {
     $group = new Group();
     $group->setCode($data['code']);
     $type = new GroupType();
     $type->setCode($data['type']);
     $type->setVariant($data['type'] === 'VARIANT');
     $group->setType($type);
     foreach ($this->getLabels($data) as $locale => $label) {
         $translation = $group->getTranslation($locale);
         $translation->setLabel($label);
         $group->addTranslation($translation);
     }
     foreach ($this->getAttributes($data) as $attribute) {
         $group->addAttribute($attribute);
     }
     return $group;
 }
 /**
  * {@inheritDoc}
  */
 public function addTranslation(\Pim\Bundle\TranslationBundle\Entity\AbstractTranslation $translation)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'addTranslation', array($translation));
     return parent::addTranslation($translation);
 }