function it_normalizes_attribute_for_versioning($attribute)
 {
     $attribute->getLocaleSpecificCodes()->willReturn(['en_US', 'fr_FR']);
     $attribute->isLocalizable()->willReturn(true);
     $attribute->isScopable()->willReturn(true);
     $size = new AttributeOption();
     $size->setCode('size');
     $en = new AttributeOptionValue();
     $fr = new AttributeOptionValue();
     $en->setLocale('en_US');
     $en->setValue('big');
     $fr->setLocale('fr_FR');
     $fr->setValue('grand');
     $size->addOptionValue($en);
     $size->addOptionValue($fr);
     $attribute->getOptions()->willReturn(new ArrayCollection([$size]));
     $attribute->getSortOrder()->willReturn(1);
     $attribute->isRequired()->willReturn(false);
     $attribute->getMaxCharacters()->willReturn(null);
     $attribute->getValidationRule()->willReturn(null);
     $attribute->getValidationRegexp()->willReturn(null);
     $attribute->isWysiwygEnabled()->willReturn(false);
     $attribute->getNumberMin()->willReturn(1);
     $attribute->getNumberMax()->willReturn(10);
     $attribute->isDecimalsAllowed()->willReturn(false);
     $attribute->isNegativeAllowed()->willReturn(false);
     $attribute->getDateMin()->willReturn(null);
     $attribute->getDateMax()->willReturn(null);
     $attribute->getMaxFileSize()->willReturn(0);
     $this->normalize($attribute, null, ['versioning' => true])->shouldReturn(['type' => 'Yes/No', 'code' => 'attribute_size', 'group' => 'size', 'unique' => 1, 'useable_as_grid_filter' => 0, 'allowed_extensions' => 'csv,xml,json', 'metric_family' => 'Length', 'default_metric_unit' => 'Centimenter', 'reference_data_name' => 'color', 'available_locales' => 'en_US,fr_FR', 'localizable' => true, 'scope' => 'Channel', 'options' => 'Code:size,en_US:big,fr_FR:grand', 'sort_order' => 1, 'required' => 0, 'max_characters' => '', 'validation_rule' => '', 'validation_regexp' => '', 'wysiwyg_enabled' => '', 'number_min' => '1', 'number_max' => '10', 'decimals_allowed' => '', 'negative_allowed' => '', 'date_min' => '', 'date_max' => '', 'metric_family' => 'Length', 'default_metric_unit' => 'Centimenter', 'max_file_size' => '0']);
 }
 /**
  * Add attribute option labels
  *
  * @param AttributeOption $option
  * @param array           $data
  */
 protected function addAttributeOptionLabels(AttributeOption $option, array $data)
 {
     foreach ($data['label'] as $locale => $data) {
         $value = new AttributeOptionValue();
         $value->setLocale($locale);
         $value->setValue($data);
         $option->addOptionValue($value);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getTranslation()
 {
     $value = $this->getOptionValue();
     if (!$value) {
         $value = new AttributeOptionValue();
         $value->setLocale($this->locale);
         $this->addOptionValue($value);
     }
     return $value;
 }
 /**
  * Create attribute options
  *
  * @param AttributeInterface $attribute
  * @param array              $data
  */
 protected function addOptions(AttributeInterface $attribute, $data)
 {
     $options = array_filter(explode('|', $data['options']));
     foreach ($options as $option) {
         $attributeOption = new AttributeOption();
         $translations = explode(',', $option);
         foreach ($translations as $translation) {
             $translation = explode(':', $translation);
             $locale = reset($translation);
             $value = end($translation);
             if ($locale == 'Code') {
                 $attributeOption->setCode($value);
             } else {
                 $optionValue = new AttributeOptionValue();
                 $optionValue->setLocale($locale);
                 $optionValue->setValue($value);
                 $attributeOption->addOptionValue($optionValue);
             }
         }
         $attribute->addOption($attributeOption);
     }
 }
 /**
  * Create attribute options
  *
  * @param AttributeInterface $attribute
  * @param array              $data
  */
 protected function addOptions(AttributeInterface $attribute, $data)
 {
     if (count($data['options']) === 1) {
         $attribute->setBackendType('option');
     } elseif (count($data['options']) > 1) {
         $attribute->setBackendType('option');
     }
     foreach ($data['options'] as $code => $values) {
         $attributeOption = new AttributeOption();
         $attributeOption->setCode($code);
         foreach ($values as $locale => $value) {
             $optionValue = new AttributeOptionValue();
             $optionValue->setLocale($locale);
             $optionValue->setValue($value);
             $attributeOption->addOptionValue($optionValue);
         }
         $attribute->addOption($attributeOption);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function setLocale($locale)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setLocale', array($locale));
     return parent::setLocale($locale);
 }