function it_massively_insert_new_products_and_update_existing_products($documentManager, $collection, $normalizer, $mongoFactory, $pendingPersister, $eventDispatcher, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4) { $mongoFactory->createMongoId()->willReturn('my_mongo_id'); $product1->getId()->willReturn("my_product_1"); $product2->getId()->willReturn(null); $product3->getId()->willReturn("my_product_3"); $product4->getId()->willReturn(null); $product1->setId(Argument::any())->shouldNotBeCalled(); $product2->setId('my_mongo_id')->shouldBeCalled(); $product3->setId(Argument::any())->shouldNotBeCalled(); $product4->setId('my_mongo_id')->shouldBeCalled(); $normalizer->normalize($product1, 'mongodb_document', ['collection_name' => 'pim_product_collection'])->willReturn(['_id' => 'my_product_1', 'normalized_product_1']); $normalizer->normalize($product2, 'mongodb_document', ['collection_name' => 'pim_product_collection'])->willReturn(['_id' => 'my_mongo_id', 'normalized_product_2']); $normalizer->normalize($product3, 'mongodb_document', ['collection_name' => 'pim_product_collection'])->willReturn(['_id' => 'my_product_3', 'normalized_product_3']); $normalizer->normalize($product4, 'mongodb_document', ['collection_name' => 'pim_product_collection'])->willReturn(['_id' => 'my_mongo_id', 'normalized_product_4']); $collection->batchInsert([['_id' => 'my_mongo_id', 'normalized_product_2'], ['_id' => 'my_mongo_id', 'normalized_product_4']])->shouldBeCalled(); $collection->update(['_id' => 'my_product_1'], ['_id' => 'my_product_1', 'normalized_product_1'])->shouldBeCalled(); $collection->update(['_id' => 'my_product_3'], ['_id' => 'my_product_3', 'normalized_product_3'])->shouldBeCalled(); $pendingPersister->persistPendingVersions([$product1, $product2, $product3, $product4])->shouldBeCalled(); $eventDispatcher->dispatch('pim_base_connector.direct_to_db_writer.pre_insert', Argument::any())->shouldBeCalled(); $eventDispatcher->dispatch('pim_base_connector.direct_to_db_writer.pre_update', Argument::any())->shouldBeCalled(); $eventDispatcher->dispatch('pim_base_connector.direct_to_db_writer.post_insert', Argument::any())->shouldBeCalled(); $eventDispatcher->dispatch('pim_base_connector.direct_to_db_writer.post_update', Argument::any())->shouldBeCalled(); $documentManager->clear()->shouldBeCalled(); $this->write([$product1, $product2, $product3, $product4]); }
function it_allows_setting_attribute_data_option_to_null(ProductInterface $product, AttributeInterface $attribute, ProductValueInterface $value) { $attribute->getCode()->willReturn('choice'); $product->getValue('choice', 'fr_FR', 'mobile')->shouldBeCalled()->willReturn($value); $value->setOption(null)->shouldBeCalled(); $this->setAttributeData($product, $attribute, null, ['locale' => 'fr_FR', 'scope' => 'mobile']); }
function it_provide_product_completeness_if_family_is_not_defined(ProductInterface $product, ChannelInterface $mobile, LocaleInterface $en) { $product->getFamily()->willReturn(null); $en->getCode()->willReturn('en_US'); $mobile->getCode()->willReturn('mobile'); $this->getProductCompleteness($product, [$mobile], [$en], 'en_US')->shouldReturn([['channels' => [['completeness' => null, 'missing' => []]], 'stats' => ['total' => 0, 'complete' => 0], 'locale' => '']]); }
function it_copies_simple_select_value_to_a_product_value($builder, $attrValidatorHelper, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, ProductInterface $product4, ProductValueInterface $fromProductValue, ProductValueInterface $toProductValue, AttributeOptionInterface $attributeOption) { $fromLocale = 'fr_FR'; $toLocale = 'fr_FR'; $toScope = 'mobile'; $fromScope = 'mobile'; $fromAttribute->getCode()->willReturn('fromAttributeCode'); $toAttribute->getCode()->willReturn('toAttributeCode'); $attrValidatorHelper->validateLocale(Argument::cetera())->shouldBeCalled(); $attrValidatorHelper->validateScope(Argument::cetera())->shouldBeCalled(); $fromProductValue->getData()->willReturn($attributeOption); $toProductValue->setOption($attributeOption)->shouldBeCalledTimes(3); $product1->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue); $product1->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue); $product2->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn(null); $product2->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue); $product3->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue); $product3->getValue('toAttributeCode', $toLocale, $toScope)->willReturn(null); $product4->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue); $product4->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue); $builder->addProductValue($product3, $toAttribute, $toLocale, $toScope)->shouldBeCalledTimes(1)->willReturn($toProductValue); $products = [$product1, $product2, $product3, $product4]; foreach ($products as $product) { $this->copyAttributeData($product, $product, $fromAttribute, $toAttribute, ['from_locale' => $fromLocale, 'to_locale' => $toLocale, 'from_scope' => $fromScope, 'to_scope' => $toScope]); } }
function it_normalizes_groups($normalizer, $structureVersionProvider, $versionManager, $versionNormalizer, $localizedConverter, GroupInterface $tshirt, GroupTypeInterface $groupType, Version $oldestLog, Version $newestLog, ArrayCollection $products, ProductInterface $product, \ArrayIterator $productsIterator) { $options = ['decimal_separator' => ',', 'date_format' => 'dd/MM/yyyy']; $tshirt->getType()->willReturn($groupType); $groupType->isVariant()->willReturn(true); $variantNormalized = ['code' => 'my_variant', 'axis' => ['color', 'size'], 'type' => 'variant', 'values' => ['number' => ['data' => 12.5, 'locale' => null, 'scope' => null], 'metric' => ['data' => 12.5, 'locale' => null, 'scope' => null], 'prices' => ['data' => 12.5, 'locale' => null, 'scope' => null], 'date' => ['data' => '2015-01-31', 'locale' => null, 'scope' => null]]]; $valuesLocalized = ['number' => ['data' => '12,5000', 'locale' => null, 'scope' => null], 'metric' => ['data' => '12,5000', 'locale' => null, 'scope' => null], 'prices' => ['data' => '12,50', 'locale' => null, 'scope' => null], 'date' => ['data' => '31/01/2015', 'locale' => null, 'scope' => null]]; $normalizer->normalize($tshirt, 'json', $options)->willReturn($variantNormalized); $localizedConverter->convertToLocalizedFormats($variantNormalized['values'], $options)->willReturn($valuesLocalized); $structureVersionProvider->getStructureVersion()->willReturn(1); $versionManager->getOldestLogEntry($tshirt)->willReturn($oldestLog); $versionManager->getNewestLogEntry($tshirt)->willReturn($newestLog); $versionNormalizer->normalize($oldestLog, 'internal_api')->willReturn('normalized_oldest_log'); $versionNormalizer->normalize($newestLog, 'internal_api')->willReturn('normalized_newest_log'); $products->getIterator()->willReturn($productsIterator); $productsIterator->rewind()->shouldBeCalled(); $productsCount = 1; $productsIterator->valid()->will(function () use(&$productsCount) { return $productsCount-- > 0; }); $productsIterator->next()->shouldBeCalled(); $productsIterator->current()->will(new ReturnPromise([$product])); $product->getId()->willReturn(42); $tshirt->getId()->willReturn(12); $tshirt->getProducts()->willReturn($products); $this->normalize($tshirt, 'internal_api', $options)->shouldReturn(['code' => 'my_variant', 'axis' => ['color', 'size'], 'type' => 'variant', 'values' => $valuesLocalized, 'products' => [42], 'meta' => ['id' => 12, 'form' => 'pim-variant-group-edit-form', 'structure_version' => 1, 'model_type' => 'variant_group', 'created' => 'normalized_oldest_log', 'updated' => 'normalized_newest_log']]); }
/** * Set data into product value * * @param ProductInterface $product * @param AttributeInterface $attribute * @param mixed $data * @param string $locale * @param string $scope */ protected function setData(ProductInterface $product, AttributeInterface $attribute, $data, $locale, $scope) { $value = $product->getValue($attribute->getCode(), $locale, $scope); if (null === $value) { $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope); } $value->setData($data); }
/** * @param ProductInterface $product */ protected function incrementCount(ProductInterface $product) { if ($product->getId()) { $this->stepExecution->incrementSummaryInfo('process'); } else { $this->stepExecution->incrementSummaryInfo('create'); } }
function it_applies_on_related_products($saver, RemoveEvent $event, CategoryInterface $object, ProductInterface $product) { $saver->saveAll([$product])->shouldBeCalled(); $event->getSubject()->willReturn($object); $object->getProducts()->willReturn([$product]); $product->removeCategory($object)->shouldBeCalled(); $this->postRemove($event)->shouldReturn(null); }
/** * Set media in the product value * * @param ProductInterface $product * @param AttributeInterface $attribute * @param FileInfoInterface|null $fileInfo * @param string|null $locale * @param string|null $scope */ protected function setMedia(ProductInterface $product, AttributeInterface $attribute, FileInfoInterface $fileInfo = null, $locale = null, $scope = null) { $value = $product->getValue($attribute->getCode(), $locale, $scope); if (null === $value) { $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope); } $value->setMedia($fileInfo); }
/** * As boolean attribute does not support "null" value (only true/false), * there are some problems to make out what should really be added to the product (specially with optional attributes) * What we add in product: * | old value | new value | attribute is in family | should be added in product | * | null | false | yes | no | * | null | false | no | yes | * * This method should be removed when boolean attribute will be rework to support 3 states: true/false/null * * @deprecated will be removed in 1.7 * * @param ProductInterface $product product to update * @param AttributeInterface $attribute attribute * @param mixed $data new value * * @return bool */ private function shouldBeSetInProduct(ProductInterface $product, AttributeInterface $attribute, $data) { $family = $product->getFamily(); if (null !== $family && in_array($attribute->getCode(), $product->getFamily()->getAttributeCodes()) && false === $data) { return false; } return true; }
function it_fails_if_one_of_the_associated_group_does_not_exist($productBuilder, $groupRepository, ProductInterface $product, AssociationInterface $xsellAssociation) { $product->getAssociations()->willReturn([$xsellAssociation]); $productBuilder->addMissingAssociations($product)->shouldBeCalled(); $product->getAssociationForTypeCode('xsell')->willReturn($xsellAssociation); $groupRepository->findOneByIdentifier('not existing group')->willReturn(null); $this->shouldThrow(InvalidArgumentException::expected('associations', 'existing group code', 'adder', 'association', 'not existing group'))->during('addFieldData', [$product, 'associations', ['xsell' => ['groups' => ['not existing group'], 'products' => []]]]); }
function it_clears_cache(StepExecution $stepExecution, ProductInterface $product1, ProductInterface $product2) { $items = [$product1, $product2]; $product1->getId()->willReturn('45'); $product2->getId()->willReturn(null); $this->setStepExecution($stepExecution); $this->write($items); }
/** * Set option into the product value * * @param ProductInterface $product * @param AttributeInterface $attribute * @param AttributeOptionInterface|null $option * @param string|null $locale * @param string|null $scope */ protected function setOption(ProductInterface $product, AttributeInterface $attribute, AttributeOptionInterface $option = null, $locale = null, $scope = null) { $value = $product->getValue($attribute->getCode(), $locale, $scope); if (null === $value) { $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope); } $value->setOption($option); }
function it_returns_flat_data_without_media(ChannelInterface $channel, ChannelManager $channelManager, ProductInterface $product, Serializer $serializer) { $product->getValues()->willReturn([]); $this->setDecimalSeparator(','); $serializer->normalize($product, 'flat', ['scopeCode' => 'foobar', 'localeCodes' => '', 'decimal_separator' => ',', 'date_format' => 'yyyy-MM-dd'])->willReturn(['normalized_product']); $channelManager->getChannelByCode('foobar')->willReturn($channel); $this->setChannel('foobar'); $this->process($product)->shouldReturn(['media' => [], 'product' => ['normalized_product']]); }
function let(ProductRepositoryInterface $productRepository, UniqueValuesSet $uniqueValuesSet, ExecutionContextInterface $context, Form $form, ProductInterface $product, ProductValueInterface $value) { $this->beConstructedWith($productRepository, $uniqueValuesSet); $product->getValue('unique_attribute')->willReturn($value); $form->getData()->willReturn($product); $context->getPropertyPath()->willReturn(self::PROPERTY_PATH); $context->getRoot()->willReturn($form); $this->initialize($context); }
function it_adds_category_field($categoryRepository, ProductInterface $product, CategoryInterface $mug, CategoryInterface $shirt, CategoryInterface $men) { $categoryRepository->findOneByIdentifier('mug')->willReturn($mug); $categoryRepository->findOneByIdentifier('shirt')->willReturn($shirt); $product->getCategories()->willReturn([$men]); $product->addCategory($mug)->shouldBeCalled(); $product->addCategory($shirt)->shouldBeCalled(); $this->addFieldData($product, 'categories', ['mug', 'shirt']); }
function it_should_removes_an_attribute_data_multi_select_value_to_a_product_value(AttributeInterface $attribute, ProductInterface $product, ProductValueInterface $productValue, AttributeOptionInterface $attributeOption, $attrOptionRepository) { $attribute->getCode()->willReturn('tshirt_style'); $attrOptionRepository->findOneByIdentifier('tshirt_style.vneck')->willReturn($attributeOption); $product->getValue('tshirt_style', 'fr_FR', 'mobile')->willReturn($productValue); $productValue->removeOption($attributeOption)->shouldBeCalled(); $data = ['vneck']; $this->removeAttributeData($product, $attribute, $data, ['locale' => 'fr_FR', 'scope' => 'mobile']); }
/** * @param ProductInterface $product * @param AttributeInterface $attribute * @param array $attributeOptions * @param string|null $locale * @param string|null $scope */ protected function removeOptions(ProductInterface $product, AttributeInterface $attribute, $attributeOptions, $locale, $scope) { $productValue = $product->getValue($attribute->getCode(), $locale, $scope); if (null !== $productValue) { foreach ($attributeOptions as $attributeOption) { $productValue->removeOption($attributeOption); } } }
/** * Returns the image path for an attribute of a product. If no image is found, returns null. * * @param ProductInterface $product * @param AttributeInterface $attribute * @param string $locale * @param string $scope * * @return string|null */ public function getImagePath(ProductInterface $product, AttributeInterface $attribute, $locale, $scope) { $productValue = $product->getValue($attribute->getCode(), $locale, $scope); $path = null; if (null !== $productValue->getMedia() && null !== $productValue->getMedia()->getKey()) { $path = sprintf('media/cache/thumbnail/%s', $productValue->getMedia()->getKey()); } return $path; }
function it_applies_on_related_products($saver, RemoveEvent $event, CategoryInterface $object, ProductInterface $product) { $saver->saveAll([$product], ['flush' => 'expected_flush_value', 'recalculate' => false, 'schedule' => false])->shouldBeCalled(); $event->getSubject()->willReturn($object); $event->getArgument('flush')->willReturn('expected_flush_value'); $object->getProducts()->willReturn([$product]); $product->removeCategory($object)->shouldBeCalled(); $this->postRemove($event)->shouldReturn(null); }
function it_sets_attribute_when_new_value_is_different_from_product_value($builder, AttributeInterface $attribute, ProductInterface $product, FamilyInterface $family, ProductValue $productValue) { $family->getAttributeCodes()->willReturn(['sku', 'is_color']); $product->getFamily()->willReturn($family); $attribute->getCode()->willReturn('is_color'); $product->getValue('is_color', null, null)->willReturn(null); $builder->addProductValue($product, $attribute, null, null)->willReturn($productValue); $this->setAttributeData($product, $attribute, true, ['locale' => null, 'scope' => null]); }
function it_hydrates_a_result_record(Builder $builder, Query $query, ProductInterface $product, Association $association, AssociationType $associationType, ProductInterface $associatedProduct1, ProductInterface $associatedProduct2, ArrayCollection $productsCollection, ArrayCollection $productIdsCollection, ArrayIterator $productsIterator, ArrayCollection $associationsCollection, ArrayIterator $associationsIterator, ArrayIterator $arrayIterator) { $product->getId()->willReturn('110ae6b98ead0ee8778b46bb'); $options = ['locale_code' => 'en_US', 'scope_code' => 'print', 'current_group_id' => null, 'attributes_configuration' => [], 'association_type_id' => 1, 'current_product' => $product]; $builder->find()->willReturn($builder); $builder->count()->willReturn($builder); $builder->getQuery()->willReturn($query); $builder->hydrate(false)->willReturn($builder); $builder->setQueryArray(Argument::any())->willReturn($builder); $builder->limit(Argument::any())->willReturn($builder); $builder->skip(Argument::any())->willReturn($builder); $product->getAssociations()->willReturn($associationsCollection); $associationsCollection->getIterator()->willReturn($associationsIterator); $associationsIterator->rewind()->shouldBeCalled(); $associationsCount = 1; $associationsIterator->valid()->will(function () use(&$associationsCount) { return $associationsCount-- > 0; }); $associationsIterator->next()->shouldBeCalled(); $associationsIterator->current()->will(new ReturnPromise([$association])); $associationsCollection->filter(Argument::any())->willReturn($associationsIterator); $associationsIterator->first()->willReturn($association); $association->getAssociationType()->willReturn($associationType); $associationType->getId()->willReturn(1); $associatedProduct1->getId()->willReturn('220ae6b98ead0ed7778b46bb'); $associatedProduct2->getId()->willReturn('330ae6b98abd0ec8778b46bb'); $association->getProducts()->willReturn($productsCollection); $productsCollection->getIterator()->willReturn($productsIterator); $productsIterator->rewind()->shouldBeCalled(); $productsCount = 2; $productsIterator->valid()->will(function () use(&$productsCount) { return $productsCount-- > 0; }); $associatedProduct1->getId()->willReturn('220ae6b98ead0ed7778b46bb'); $associatedProduct2->getId()->willReturn('330ae6b98abd0ec8778b46bb'); $association->getProducts()->willReturn($productsCollection); $productsCollection->getIterator()->willReturn($productsIterator); $productsIterator->rewind()->shouldBeCalled(); $productsCount = 2; $productsIterator->valid()->will(function () use(&$productsCount) { return $productsCount-- > 0; }); $productsIterator->next()->shouldBeCalled(); $productsIterator->current()->will(new ReturnPromise([$associatedProduct1, $associatedProduct2])); $productsCollection->map(Argument::any())->willReturn($productIdsCollection); $productIdsCollection->toArray()->willReturn(['220ae6b98ead0ed7778b46bb', '330ae6b98abd0ec8778b46bb']); $queryDefinition = ['type' => 1, 'sort' => ['normalizedData.is_associated' => -1, '_id' => 1], 'limit' => 10, 'skip' => 0, 'query' => ['_id' => ['$ne' => \MongoId::__set_state(['$id' => '110ae6b98ead0ee8778b46bb'])]], 'newObj' => []]; $query->getQuery()->willReturn($queryDefinition); $fixture = ['_id' => \MongoId::__set_state(['$id' => '550ae6b98ead0ee8778b46bb']), 'normalizedData' => [], 'sku' => ['attribute' => ['code' => 'sku', 'attributeType' => 'text', 'backendType' => 'text'], 'locale' => null, 'scope' => null, 'value' => 'mysku'], 'name' => ['attribute' => ['code' => 'name', 'attributeType' => 'text', 'backendType' => 'text'], 'locale' => 'fr_FR', 'scope' => null], 'desc' => ['attribute' => ['code' => 'desc', 'attributeType' => 'text', 'backendType' => 'text'], 'locale' => 'fr_FR', 'scope' => 'print'], 'is_associated' => 1]; $query->execute()->willReturn($arrayIterator); $arrayIterator->toArray()->willReturn([$fixture]); $rows = $this->hydrate($builder, $options); $rows->shouldHaveCount(1); $firstResult = $rows[0]; $firstResult->shouldBeAnInstanceOf('\\Oro\\Bundle\\DataGridBundle\\Datasource\\ResultRecord'); }
/** * Adds options into the product value * * @param ProductInterface $product * @param AttributeInterface $attribute * @param array $attributeOptions * @param string $locale * @param string $scope */ protected function addOptions(ProductInterface $product, AttributeInterface $attribute, $attributeOptions, $locale, $scope) { $value = $product->getValue($attribute->getCode(), $locale, $scope); if (null === $value) { $value = $this->productBuilder->addProductValue($product, $attribute, $locale, $scope); } foreach ($attributeOptions as $attributeOption) { $value->addOption($attributeOption); } }
/** * Remove prices from product value * * @param ProductInterface $product * @param AttributeInterface $attribute * @param mixed $data * @param string $locale * @param string $scope */ protected function removePrices(ProductInterface $product, AttributeInterface $attribute, $data, $locale, $scope) { $productValue = $product->getValue($attribute->getCode(), $locale, $scope); if (null !== $productValue) { foreach ($data as $price) { $priceToRemove = $productValue->getPrice($price['currency']); $productValue->removePrice($priceToRemove); } } }
/** * Get missing axis codes of a product given a variant group * * @param ProductInterface $product * @param GroupInterface $variantGroup * * @return array */ protected function getMissingAxisCodes(ProductInterface $product, GroupInterface $variantGroup) { $missingAxisCodes = []; foreach ($variantGroup->getAxisAttributes() as $attribute) { $value = $product->getValue($attribute->getCode()); if (null === $value || null === $value->getData()) { $missingAxisCodes[] = $attribute->getCode(); } } return $missingAxisCodes; }
/** * Add products and groups to associations * * @param ProductInterface $product * @param mixed $data */ protected function addProductsAndGroupsToAssociations(ProductInterface $product, $data) { foreach ($data as $typeCode => $items) { $association = $product->getAssociationForTypeCode($typeCode); if (null === $association) { throw InvalidArgumentException::expected('associations', 'existing association type code', 'adder', 'association', $typeCode); } $this->addAssociatedProducts($association, $items['products']); $this->addAssociatedGroups($association, $items['groups']); } }
/** * Copy single value * * @param ProductInterface $fromProduct * @param ProductInterface $toProduct * @param AttributeInterface $fromAttribute * @param AttributeInterface $toAttribute * @param string $fromLocale * @param string $toLocale * @param string $fromScope * @param string $toScope */ protected function copySingleValue(ProductInterface $fromProduct, ProductInterface $toProduct, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, $fromLocale, $toLocale, $fromScope, $toScope) { $fromValue = $fromProduct->getValue($fromAttribute->getCode(), $fromLocale, $fromScope); if (null !== $fromValue) { $toValue = $toProduct->getValue($toAttribute->getCode(), $toLocale, $toScope); if (null === $toValue) { $toValue = $this->productBuilder->addProductValue($toProduct, $toAttribute, $toLocale, $toScope); } $this->copyOptions($fromValue, $toValue); } }
function it_removes_groups_field($groupRepository, ProductInterface $product, GroupInterface $packGroup, GroupInterface $crossGroup, GroupTypeInterface $nonVariantType) { $groupRepository->findOneByIdentifier('pack')->willReturn($packGroup); $groupRepository->findOneByIdentifier('cross')->willReturn($crossGroup); $packGroup->getType()->willReturn($nonVariantType); $crossGroup->getType()->willReturn($nonVariantType); $nonVariantType->isVariant()->willReturn(false); $product->removeGroup($packGroup)->shouldBeCalled(); $product->removeGroup($crossGroup)->shouldBeCalled(); $this->removeFieldData($product, 'groups', ['pack', 'cross']); }
function it_sets_null_value_when_receiving_empty_string(AttributeInterface $attribute, ProductInterface $product1, ProductInterface $product2, ProductInterface $product3, $builder, ProductValue $productValue) { $locale = 'fr_FR'; $scope = 'mobile'; $data = ''; $attribute->getCode()->willReturn('attributeCode'); $productValue->setData(null)->shouldBeCalled(); $builder->addProductValue($product2, $attribute, $locale, $scope)->willReturn($productValue); $product1->getValue('attributeCode', $locale, $scope)->shouldBeCalled()->willReturn($productValue); $this->setAttributeData($product1, $attribute, $data, ['locale' => $locale, 'scope' => $scope]); }
function it_removes_categories_to_a_product($categoryRepository, CategoryInterface $bookCategory, CategoryInterface $penCategory, CategoryInterface $bluePenCategory, ProductInterface $bookProduct, ProductInterface $bluePenProduct) { $categoryRepository->findOneByIdentifier('book_category')->willReturn($bookCategory); $bookProduct->removeCategory($bookCategory)->shouldBeCalled(); $categoryRepository->findOneByIdentifier('pen_category')->willReturn($penCategory); $categoryRepository->findOneByIdentifier('blue_pen_category')->willReturn($bluePenCategory); $bluePenProduct->removeCategory($penCategory)->shouldBeCalled(); $bluePenProduct->removeCategory($bluePenCategory)->shouldBeCalled(); $this->removeFieldData($bookProduct, 'categories', ['book_category']); $this->removeFieldData($bluePenProduct, 'categories', ['pen_category', 'blue_pen_category']); }