/** * @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); }
/** * @expectedException \LogicException * @expectedExceptionMessage Several attribute labels found by the same locale ID. */ public function testGetLabelByLocaleIdException() { $locale = $this->createLocale(1); $firstLabel = new AttributeLabel(); $firstLabel->setLocale($locale); $secondLabel = new AttributeLabel(); $secondLabel->setLocale($locale); $attribute = new Attribute(); $attribute->resetLabels([$firstLabel, $secondLabel]); $attribute->getLabelByLocaleId(1); }