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 for __toString method
  */
 public function testToString()
 {
     // Change value and assert new
     $newCode = 'toStringCode';
     $expectedCode = '[' . $newCode . ']';
     $this->group->setCode($newCode);
     $this->assertEquals($expectedCode, $this->group->__toString());
     $newLabel = 'toStringLabel';
     $this->assertEntity($this->group->setLocale('en_US'));
     $this->assertEntity($this->group->setLabel($newLabel));
     $this->assertEquals($newLabel, $this->group->__toString());
     // if no translation, assert the expected code is returned
     $this->group->setLocale('fr_FR');
     $this->assertEquals($expectedCode, $this->group->__toString());
     // if empty translation, assert the expected code is returned
     $this->group->setLabel('');
     $this->assertEquals($expectedCode, $this->group->__toString());
 }
 /**
  * {@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;
 }
 /**
  * @param string $code
  * @param string $label
  * @param string $type
  * @param array  $attributes
  * @param array  $products
  */
 protected function createProductGroup($code, $label, $type, array $attributes, array $products = [])
 {
     $group = new Group();
     $group->setCode($code);
     $group->setLocale('en_US')->setLabel($label);
     // TODO translation refactoring
     $type = $this->getGroupType($type);
     $group->setType($type);
     foreach ($attributes as $attributeCode) {
         $attribute = $this->getAttribute($attributeCode);
         $group->addAttribute($attribute);
     }
     // TODO replace by call to a saver
     $this->validate($group);
     $this->persist($group);
     $this->flush($group);
     foreach ($products as $sku) {
         if (!empty($sku)) {
             $product = $this->getProduct($sku);
             $product->addGroup($group);
             $this->validate($product);
             $this->getProductSaver()->save($product);
         }
     }
 }
 /**
  * Create a group entity
  *
  * @param string $code
  *
  * @return Group
  */
 protected function createGroup($code)
 {
     $group = new Group();
     $group->setCode($code);
     return $group;
 }
 /**
  * {@inheritDoc}
  */
 public function setCode($code)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCode', array($code));
     return parent::setCode($code);
 }