function it_denormalizes_an_existing_group_with_properties($groupRepository, Group $group, GroupType $type, AttributeInterface $size, AttributeInterface $color, GroupTranslation $translationUS) { $groupRepository->findOneByIdentifier('tshirt')->willReturn(null); $group->getId()->willReturn(42); $group->setCode('tshirt')->shouldBeCalled(); $group->setType(Argument::any())->shouldNotBeCalled(); $group->setAttributes(Argument::any())->shouldNotBeCalled(); $group->getTranslation('en_US')->willReturn($translationUS); $translationUS->setLabel('My T-shirt')->shouldBeCalled(); $group->addTranslation($translationUS)->shouldBeCalled(); $this->denormalize(['code' => 'tshirt', 'label-en_US' => 'My T-shirt'], self::ENTITY_CLASS, self::FORMAT_CSV, ['entity' => $group])->shouldReturn($group); }
/** * {@inheritdoc} * * @return Group */ protected function createEntity(array $data) { $group = new Group(); $group->setCode($data['code']); $type = new GroupType(); $type->setCode($data['type']); $type->setVariant($data['type'] === 'VARIANT'); $group->setType($type); foreach ($this->getLabels($data) as $locale => $label) { $translation = $group->getTranslation($locale); $translation->setLabel($label); $group->addTranslation($translation); } foreach ($this->getAttributes($data) as $attribute) { $group->addAttribute($attribute); } return $group; }
/** * {@inheritDoc} */ public function getTranslation($locale = NULL) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getTranslation', array($locale)); return parent::getTranslation($locale); }