function it_generates_a_query_to_update_product_select_attributes($namingUtility, AttributeOptionValue $bleu, AttributeOption $blue, AbstractAttribute $color) { $bleu->getOption()->willReturn($blue); $bleu->getLocale()->willReturn('fr_FR'); $blue->getAttribute()->willReturn($color); $namingUtility->getAttributeNormFields($color)->willReturn(['normalizedData.color-fr_FR', 'normalizedData.color-en_US']); $blue->getCode()->willReturn('blue'); $this->generateQuery($bleu, 'value', 'Bleu', 'Bleus')->shouldReturn([[['normalizedData.color-fr_FR' => ['$elemMatch' => ['code' => 'blue']]], ['$set' => ['normalizedData.color-fr_FR.$.optionValues.fr_FR.value' => 'Bleus']], ['multiple' => true]], [['normalizedData.color-en_US' => ['$elemMatch' => ['code' => 'blue']]], ['$set' => ['normalizedData.color-en_US.$.optionValues.fr_FR.value' => 'Bleus']], ['multiple' => true]]]); }
function it_normalizes_attribute_option(AttributeOption $option, AttributeOptionValue $valueUs, AttributeOptionValue $valueFr) { $option->getId()->willReturn(42); $option->getCode()->willReturn('red'); $valueUs->getLocale()->willReturn('en_US'); $valueUs->getValue()->willReturn('Red'); $valueFr->getLocale()->willReturn('fr_FR'); $valueFr->getValue()->willReturn('Rouge'); $option->getOptionValues()->willReturn([$valueUs, $valueFr]); $this->normalize($option, 'mongodb_json', [])->shouldReturn(['id' => 42, 'code' => 'red', 'optionValues' => ['en_US' => ['value' => 'Red', 'locale' => 'en_US'], 'fr_FR' => ['value' => 'Rouge', 'locale' => 'fr_FR']]]); }
function it_normalizes_the_whole_option(AttributeOption $option, AbstractAttribute $attribute, AttributeOptionValue $valueEn, AttributeOptionValue $valueFr) { $option->getCode()->willReturn('red'); $option->getAttribute()->willReturn($attribute); $option->isDefault()->willReturn(true); $attribute->getCode()->willReturn('color'); $option->getOptionValues()->willReturn(['en_US' => $valueEn, 'fr_FR' => $valueFr]); $valueEn->getLocale()->willReturn('en_US'); $valueEn->getValue()->willReturn('Red'); $valueFr->getLocale()->willReturn('fr_FR'); $valueFr->getValue()->willReturn('Rouge'); $this->normalize($option, null, ['locales' => ['en_US', 'fr_FR', 'de_DE']])->shouldReturn(['attribute' => 'color', 'code' => 'red', 'default' => '1', 'label-en_US' => 'Red', 'label-fr_FR' => 'Rouge', 'label-de_DE' => '']); }
/** * {@inheritDoc} */ public function getLocale() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getLocale', array()); return parent::getLocale(); }