function it_normalizes_family($normalizer, FamilyInterface $family, AttributeInterface $sku) { $sku->getCode()->willReturn('sku'); $family->getCode()->willReturn('mongo'); $family->getAttributeAsLabel()->willReturn($sku); $normalizer->normalize($family, 'mongodb_json', [])->willReturn(['label' => 'translations']); $this->normalize($family, 'mongodb_json', [])->shouldReturn(['code' => 'mongo', 'label' => 'translations', 'attributeAsLabel' => 'sku']); }
/** * {@inheritdoc} */ public function getLabel($locale = null) { if ($this->family) { if ($attributeAsLabel = $this->family->getAttributeAsLabel()) { if ($locale) { $this->setLocale($locale); } if ($value = $this->getValue($attributeAsLabel->getCode())) { $data = $value->getData(); if (!empty($data)) { return (string) $data; } } } } return (string) $this->getIdentifier()->getData(); }