function it_throws_an_error_if_type_is_unknown(GroupInterface $group) { $group->setCode('mycode')->shouldBeCalled(); $group->getId()->willReturn(null); $values = ['code' => 'mycode', 'type' => 'UNKNOWN']; $this->shouldThrow(new \InvalidArgumentException('Type "UNKNOWN" does not exist'))->during('update', [$group, $values, []]); }
function it_throws_an_exception_if_attribute_is_unknown($attributeRepository, GroupInterface $group) { $group->setCode('mycode')->shouldBeCalled(); $attributeRepository->findOneByIdentifier('foo')->willReturn(null); $group->getId()->willReturn(null); $values = ['code' => 'mycode', 'axis' => ['foo']]; $this->shouldThrow(new \InvalidArgumentException('Attribute "foo" does not exist'))->during('update', [$group, $values, []]); }
function it_throws_an_error_if_axis_is_updated(GroupInterface $variantGroup) { $variantGroup->setCode('mycode')->shouldBeCalled(); $variantGroup->getId()->willReturn(42); $attribute = new Attribute(); $attribute->setCode('other'); $variantGroup->getAxisAttributes()->willReturn(new ArrayCollection([$attribute])); $values = ['code' => 'mycode', 'axis' => ['main_color']]; $this->shouldThrow(new \InvalidArgumentException('Attributes: This property cannot be changed.'))->during('update', [$variantGroup, $values, []]); }
/** * @param GroupInterface $group * @param string $code */ protected function setCode(GroupInterface $group, $code) { $group->setCode($code); }
/** * @param GroupInterface $variantGroup * @param string $code */ protected function setCode(GroupInterface $variantGroup, $code) { $variantGroup->setCode($code); }
/** * @param GroupInterface $group * @param array $data */ protected function setCode(GroupInterface $group, $data) { if (isset($data['code'])) { $group->setCode($data['code']); } }