public function it_throws_an_exception_if_attribute_does_not_exist($attributeRepository, FamilyInterface $family, AttributeInterface $priceAttribute)
 {
     $data = ['code' => 'mycode', 'attributes' => ['sku', 'name', 'description', 'price'], 'attribute_as_label' => 'name', 'requirements' => ['mobile' => ['sku', 'name'], 'print' => ['sku', 'name', 'description']], 'labels' => ['fr_FR' => 'Moniteurs', 'en_US' => 'PC Monitors']];
     $family->setCode('mycode')->shouldBeCalled();
     $family->getAttributes()->willReturn([$priceAttribute]);
     $family->removeAttribute($priceAttribute)->shouldBeCalled();
     $attributeRepository->findOneByIdentifier('sku')->willReturn(null);
     $this->shouldThrow(new \InvalidArgumentException(sprintf('Attribute with "%s" code does not exist', 'sku')))->during('update', [$family, $data]);
 }
 /**
  * @param FamilyInterface $family
  * @param array           $data
  *
  * @throws \InvalidArgumentException
  */
 protected function addAttributes(FamilyInterface $family, array $data)
 {
     foreach ($family->getAttributes() as $attribute) {
         if (AttributeTypes::IDENTIFIER !== $attribute->getAttributeType()) {
             $family->removeAttribute($attribute);
         }
     }
     foreach ($data as $attributeCode) {
         if (null !== ($attribute = $this->attributeRepository->findOneByIdentifier($attributeCode))) {
             $family->addAttribute($attribute);
         } else {
             throw new \InvalidArgumentException(sprintf('Attribute with "%s" code does not exist', $attributeCode));
         }
     }
 }