/**
  * @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 properties found by the same field and locale ID.
  */
 public function testGetPropertyByFieldAndWebsiteIdException()
 {
     $website = $this->createWebsite(1);
     $firstProperty = new AttributeProperty();
     $firstProperty->setField(AttributeProperty::FIELD_USE_FOR_SEARCH)->setWebsite($website);
     $secondProperty = new AttributeProperty();
     $secondProperty->setField(AttributeProperty::FIELD_USE_FOR_SEARCH)->setWebsite($website);
     $attribute = new Attribute();
     $attribute->resetProperties([$firstProperty, $secondProperty]);
     $attribute->getPropertyByFieldAndWebsiteId(AttributeProperty::FIELD_USE_FOR_SEARCH, 1);
 }