function it_normalizes_a_variant_group_with_its_values($transNormalizer, $valuesDenormalizer, $group, GroupTypeInterface $groupType, AttributeInterface $attr, ProductTemplateInterface $productTemplate) { $groupType->getCode()->willReturn('VARIANT'); $groupType->isVariant()->willReturn(true); $group->getCode()->willReturn('laser_sabers'); $valuesData = ['name' => 'Light saber model', 'size' => '120']; $context = ['with_variant_group_values' => true]; $format = 'csv'; $productTemplate->getValuesData()->willReturn($valuesData); $group->getProductTemplate()->willReturn($productTemplate); $group->getType()->willReturn($groupType); $attr->getCode()->willReturn('light_color'); $group->getAxisAttributes()->willReturn([$attr]); $transNormalizer->normalize($group, $format, $context)->willReturn([]); $this->normalize($group, $format, $context)->shouldReturn(['code' => 'laser_sabers', 'type' => 'VARIANT', 'axis' => ['light_color'], 'values' => ['name' => 'Light saber model', 'size' => '120']]); }
function it_normalizes_a_variant_group_with_its_values_on_versioning_context($transNormalizer, $valuesDenormalizer, $group, CustomSerializer $serializer, GroupTypeInterface $groupType, AttributeInterface $attr, ProductTemplateInterface $productTemplate, ProductValueInterface $productValue1) { $groupType->getCode()->willReturn('VARIANT'); $groupType->isVariant()->willReturn(true); $group->getCode()->willReturn('lego'); $valuesData = ['name' => 'Light saber model', 'size' => '120']; $context = ['versioning' => true]; $format = 'csv'; $productTemplate->getValuesData()->willReturn($valuesData); $valuesDenormalizer->denormalize($valuesData, 'ProductValue[]', 'json')->willReturn([$productValue1]); $newContext = array_merge($context, ['with_variant_group_values' => true]); $serializer->normalize($productValue1, $format, ['entity' => 'product'] + $newContext)->willReturn(['age' => '6+']); $group->getProductTemplate()->willReturn($productTemplate); $group->getType()->willReturn($groupType); $attr->getCode()->willReturn('model'); $group->getAxisAttributes()->willReturn([$attr]); $transNormalizer->normalize($group, $format, $context)->willReturn([]); $this->setSerializer($serializer); $this->normalize($group, $format, $context)->shouldReturn(['code' => 'lego', 'type' => 'VARIANT', 'axis' => 'model', 'age' => '6+']); }