/**
  * @param array|null $view
  * @param Attribute|null $model
  * @param Attribute|null $attribute
  * @dataProvider reverseTransformDataProvider
  */
 public function testReverseTransform($view, $model, Attribute $attribute = null)
 {
     if (!$attribute) {
         $attribute = new Attribute();
     }
     $transformer = new AttributeTransformer($this->managerRegistry, $this->typeRegistry, $attribute);
     $actualModel = $transformer->reverseTransform($view);
     if ($model && $actualModel) {
         // collections should be compared without keys influence
         $model->resetLabels($model->getLabels()->toArray());
         $model->resetProperties($model->getProperties()->toArray());
         $model->resetDefaultValues($model->getDefaultValues()->toArray());
         $model->resetOptions($model->getOptions()->toArray());
         $actualModel->resetLabels($actualModel->getLabels()->toArray());
         $actualModel->resetProperties($actualModel->getProperties()->toArray());
         $actualModel->resetDefaultValues($actualModel->getDefaultValues()->toArray());
         $actualModel->resetOptions($actualModel->getOptions()->toArray());
     }
     $this->assertEquals($model, $actualModel);
 }
 /**
  * @param Attribute $attribute
  * @return array
  */
 public function getDefaultOptions(Attribute $attribute)
 {
     $result = [];
     foreach ($attribute->getOptions() as $option) {
         $masterOptionId = $this->getMasterOptionId($option);
         $localeId = $this->getOptionLocaleId($option);
         // if master option
         if ($option->getId() == $masterOptionId) {
             $result[$masterOptionId]['master_option_id'] = $masterOptionId;
             $result[$masterOptionId]['order'] = $option->getOrder();
         }
         $fallback = $option->getFallback();
         if ($fallback) {
             $value = new FallbackType($fallback);
         } else {
             $value = $option->getValue();
         }
         $result[$masterOptionId]['data'][$localeId] = ['value' => $value, 'is_default' => false];
     }
     foreach ($attribute->getDefaultValues() as $defaultValue) {
         $option = $defaultValue->getOption();
         if (!$option) {
             continue;
         }
         $masterOptionId = $this->getMasterOptionId($option);
         $localeId = $this->getOptionLocaleId($option);
         $result[$masterOptionId]['data'][$localeId]['is_default'] = true;
     }
     usort($result, function ($a, $b) {
         if ($a['order'] == $b['order']) {
             return 0;
         }
         return $a['order'] > $b['order'] ? 1 : -1;
     });
     return $result;
 }