/**
  * @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);
 }
Пример #2
0
 /**
  * @expectedException \LogicException
  * @expectedExceptionMessage Several attribute default values found by the same locale ID and option ID.
  */
 public function testGetDefaultValueByLocaleIdAndOptionIdException()
 {
     $locale = $this->createLocale(1);
     $option = $this->createAttributeOption(2);
     $firstValue = new AttributeDefaultValue();
     $firstValue->setLocale($locale)->setOption($option);
     $secondValue = new AttributeDefaultValue();
     $secondValue->setLocale($locale)->setOption($option);
     $attribute = new Attribute();
     $attribute->resetDefaultValues([$firstValue, $secondValue]);
     $attribute->getDefaultValueByLocaleIdAndOptionId(1, 2);
 }