/**
  * Get the magento group id.
  *
  * @param AbstractAttribute $pimAttribute
  * @param Family            $pimFamily
  *
  * @return int|null
  */
 protected function getGroupId(AbstractAttribute $pimAttribute, Family $pimFamily)
 {
     $pimGroup = $pimAttribute->getGroup();
     if ($pimGroup !== null) {
         $magentoGroupId = $this->attributeGroupMappingManager->getIdFromGroup($pimGroup, $pimFamily, $this->getSoapUrl());
     } else {
         $magentoGroupId = null;
     }
     return $magentoGroupId;
 }
 function it_sends_attribute_with_group_and_family_to_create_on_magento_webservice($webservice, AbstractAttribute $attribute, AttributeMappingManager $attributeMappingManager, AttributeGroupMappingManager $attributeGroupMappingManager, FamilyMappingManager $familyMappingManager, AttributeGroup $group, Family $family, $magentoMappingMerger, MappingCollection $mapping)
 {
     $attributes = [[$attribute, ['create' => ['attributeName' => 'attribute_code']]]];
     $this->setMagentoUrl(null);
     $this->setWsdlUrl('/api/soap/?wsdl');
     $attribute->getCode()->willReturn('attributeName');
     $attribute->getFamilies()->willReturn([$family]);
     $attribute->getGroup()->willReturn($group);
     $magentoMappingMerger->getMapping()->willReturn($mapping);
     $mapping->getTarget($attribute)->willReturn(12);
     $mapping->getSource(12)->willReturn(12);
     $group->getCode()->willReturn('group_name');
     $familyMappingManager->getIdFromFamily(Argument::any(), '/api/soap/?wsdl')->willReturn(414);
     $webservice->addAttributeGroupToAttributeSet(414, 'group_name')->shouldBeCalled()->willReturn(797);
     $webservice->createAttribute(Argument::any())->willReturn(12);
     $webservice->addAttributeToAttributeSet(12, 414, 797)->shouldBeCalled();
     $attributeGroupMappingManager->registerGroupMapping($group, $family, 797, '/api/soap/?wsdl')->shouldBeCalled();
     $attributeGroupMappingManager->getIdFromGroup($group, $family, '/api/soap/?wsdl')->willReturn(797);
     $attributeMappingManager->registerAttributeMapping($attribute, 12, '/api/soap/?wsdl')->shouldBeCalled();
     $this->write($attributes);
 }