function it_does_not_update_attributes_from_the_default_group($attributeGroupRepository, AttributeGroupInterface $attributeGroup)
 {
     $values = ['code' => 'other', 'sort_order' => 1, 'attributes' => ['foo'], 'label' => ['en_US' => 'Other', 'fr_FR' => 'Autre']];
     $attributeGroup->getCode()->willReturn('other');
     $attributeGroup->setCode('other')->shouldBeCalled();
     $attributeGroup->setSortOrder(1)->shouldBeCalled();
     $attributeGroup->setLocale('en_US')->shouldBeCalled();
     $attributeGroup->setLocale('fr_FR')->shouldBeCalled();
     $attributeGroup->setLabel('Other')->shouldBeCalled();
     $attributeGroup->setLabel('Autre')->shouldBeCalled();
     $attributeGroupRepository->findDefaultAttributeGroup()->shouldNotBeCalled();
     $attributeGroup->getAttributes()->shouldNotBeCalled();
     $this->update($attributeGroup, $values, []);
 }
 function it_updates_an_attribute_group($attributeRepository, AttributeGroupInterface $attributeGroup, AttributeInterface $attributeSize, AttributeInterface $attributeMainColor)
 {
     $values = ['code' => 'sizes', 'sort_order' => 1, 'attributes' => ['size', 'main_color'], 'label' => ['en_US' => 'Sizes', 'fr_FR' => 'Tailles']];
     $attributeGroup->setCode('sizes')->shouldBeCalled();
     $attributeGroup->setSortOrder(1)->shouldBeCalled();
     $attributeRepository->findOneByIdentifier('size')->willReturn($attributeSize);
     $attributeRepository->findOneByIdentifier('main_color')->willReturn($attributeMainColor);
     $attributeGroup->addAttribute($attributeSize)->shouldBeCalled();
     $attributeGroup->addAttribute($attributeMainColor)->shouldBeCalled();
     $attributeGroup->setLocale('en_US')->shouldBeCalled();
     $attributeGroup->setLocale('fr_FR')->shouldBeCalled();
     $attributeGroup->setLabel('Sizes')->shouldBeCalled();
     $attributeGroup->setLabel('Tailles')->shouldBeCalled();
     $this->update($attributeGroup, $values, []);
 }
 /**
  * @param AttributeGroupInterface $attributeGroup
  * @param string                  $field
  * @param mixed                   $data
  *
  * @throws \InvalidArgumentException
  */
 protected function setData($attributeGroup, $field, $data)
 {
     if ('code' == $field) {
         $attributeGroup->setCode($data);
     } elseif ('sort_order' == $field) {
         $attributeGroup->setSortOrder($data);
     } elseif ('attributes' == $field) {
         $this->setAttributes($attributeGroup, $data);
     } elseif ('label' == $field) {
         foreach ($data as $locale => $label) {
             $attributeGroup->setLocale($locale);
             $attributeGroup->setLabel($label);
         }
     }
 }
 /**
  * @param AttributeGroupInterface $attributeGroup
  * @param string                  $field
  * @param mixed                   $data
  *
  * @throws \InvalidArgumentException
  */
 protected function setData($attributeGroup, $field, $data)
 {
     if ('code' == $field) {
         $attributeGroup->setCode($data);
     } elseif ('sort_order' == $field) {
         $attributeGroup->setSortOrder($data);
     } elseif ('attributes' == $field) {
         foreach ($data as $attributeCode) {
             $attribute = $this->findAttribute($attributeCode);
             if (null !== $attribute) {
                 $attributeGroup->addAttribute($attribute);
             } else {
                 throw new \InvalidArgumentException(sprintf('Attribute with "%s" code does not exist', $attributeCode));
             }
         }
     } elseif ('label' == $field) {
         foreach ($data as $locale => $label) {
             $attributeGroup->setLocale($locale);
             $attributeGroup->setLabel($label);
         }
     }
 }