本文整理汇总了PHP中Pim\Component\Catalog\Model\GroupInterface类的典型用法代码示例。如果您正苦于以下问题:PHP GroupInterface类的具体用法?PHP GroupInterface怎么用?PHP GroupInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GroupInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
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, []]);
}
示例2:
function it_provides_formatted_batch_config_for_the_job(GroupInterface $oroTshirt)
{
$oroTshirt->getCode()->willReturn('oro_tshirt');
$this->setGroup($oroTshirt);
$this->setFilters([['id', 'IN', ['22', '7']]]);
$this->getBatchConfig()->shouldReturn('{\\"filters\\":[[\\"id\\",\\"IN\\",[\\"22\\",\\"7\\"]]],\\"actions\\":{\\"field\\":\\"variant_group\\",\\"value\\":\\"oro_tshirt\\"}}');
}
示例3: use
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']]);
}
示例4:
function it_provides_formatted_batch_config_for_the_job(GroupInterface $oroTshirt)
{
$oroTshirt->getCode()->willReturn('oro_tshirt');
$this->setGroup($oroTshirt);
$this->setFilters([['id', 'IN', ['22', '7']]]);
$this->getBatchConfig()->shouldReturn(['filters' => [['id', 'IN', ['22', '7']]], 'actions' => ['field' => 'variant_group', 'value' => 'oro_tshirt']]);
}
示例5:
function it_fails_if_the_group_code_is_not_found($groupRepository, ProductInterface $product, GroupInterface $pack, GroupTypeInterface $nonVariantType)
{
$groupRepository->findOneByIdentifier('not valid code')->willReturn(null);
$pack->getType()->willReturn($nonVariantType);
$nonVariantType->isVariant()->willReturn(false);
$this->shouldThrow(InvalidArgumentException::expected('variant_group', 'existing variant group code', 'setter', 'variant_group', 'not valid code'))->during('setFieldData', [$product, 'variant_group', 'not valid code']);
}
示例6:
function it_normalize_products($productNormalizer, $versionNormalizer, $versionManager, $localeRepository, $structureVersionProvider, $formProvider, $localizedConverter, ProductInterface $mug, AssociationInterface $upsell, AssociationTypeInterface $groupType, GroupInterface $group, ArrayCollection $groups)
{
$options = ['decimal_separator' => ',', 'date_format' => 'dd/MM/yyyy'];
$productNormalized = ['enabled' => true, 'categories' => ['kitchen'], 'family' => '', 'values' => ['normalized_property' => ['data' => 'a nice normalized property', 'locale' => null, 'scope' => null], '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 = ['normalized_property' => ['data' => 'a nice normalized property', 'locale' => null, 'scope' => null], 'number' => ['data' => '12,5000', 'locale' => null, 'scope' => null], 'metric' => ['data' => '12,5000', 'locale' => null, 'scope' => null], 'prices' => ['data' => '12,5', 'locale' => null, 'scope' => null], 'date' => ['data' => '31/01/2015', 'locale' => null, 'scope' => null]];
$productNormalizer->normalize($mug, 'json', $options)->willReturn($productNormalized);
$localizedConverter->convertToLocalizedFormats($productNormalized['values'], $options)->willReturn($valuesLocalized);
$mug->getId()->willReturn(12);
$versionManager->getOldestLogEntry($mug)->willReturn('create_version');
$versionNormalizer->normalize('create_version', 'internal_api')->willReturn('normalized_create_version');
$versionManager->getNewestLogEntry($mug)->willReturn('update_version');
$versionNormalizer->normalize('update_version', 'internal_api')->willReturn('normalized_update_version');
$localeRepository->getActivatedLocaleCodes()->willReturn(['en_US', 'fr_FR']);
$mug->getLabel('en_US')->willReturn('A nice Mug!');
$mug->getLabel('fr_FR')->willReturn('Un très beau Mug !');
$mug->getAssociations()->willReturn([$upsell]);
$upsell->getAssociationType()->willReturn($groupType);
$groupType->getCode()->willReturn('group');
$upsell->getGroups()->willReturn($groups);
$groups->toArray()->willReturn([$group]);
$group->getId()->willReturn(12);
$structureVersionProvider->getStructureVersion()->willReturn(12);
$formProvider->getForm($mug)->willReturn('product-edit-form');
$this->normalize($mug, 'internal_api', $options)->shouldReturn(['enabled' => true, 'categories' => ['kitchen'], 'family' => '', 'values' => $valuesLocalized, 'meta' => ['form' => 'product-edit-form', 'id' => 12, 'created' => 'normalized_create_version', 'updated' => 'normalized_update_version', 'model_type' => 'product', 'structure_version' => 12, 'label' => ['en_US' => 'A nice Mug!', 'fr_FR' => 'Un très beau Mug !'], 'associations' => ['group' => ['groupIds' => [12]]]]]);
}
示例7: normalizeVariantGroupValues
/**
* Normalize the variant group values
*
* @param GroupInterface $variantGroup
*
* @return array
*/
protected function normalizeVariantGroupValues(GroupInterface $variantGroup)
{
if (null === ($template = $variantGroup->getProductTemplate())) {
return [];
}
return $template->getValuesData();
}
示例8:
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, []]);
}
示例9: bindProducts
/**
* Bind products
*
* @param GroupInterface $group
* @param array $appendProducts
* @param array $removeProducts
*/
protected function bindProducts(GroupInterface $group, array $appendProducts, array $removeProducts)
{
foreach ($appendProducts as $product) {
$group->addProduct($product);
}
foreach ($removeProducts as $product) {
$group->removeProduct($product);
}
}
示例10: validateAttributeAxis
/**
* @param VariantGroupAxis $constraint
* @param GroupInterface $variantGroup
*/
protected function validateAttributeAxis(VariantGroupAxis $constraint, GroupInterface $variantGroup)
{
$allowedTypes = [AttributeTypes::OPTION_SIMPLE_SELECT, AttributeTypes::REFERENCE_DATA_SIMPLE_SELECT];
foreach ($variantGroup->getAxisAttributes() as $attribute) {
if (!in_array($attribute->getAttributeType(), $allowedTypes)) {
$this->addInvalidAxisViolation($constraint, $variantGroup->getCode(), $attribute->getCode());
}
}
}
示例11:
function it_validates_products_with_one_variant_group($context, $onlyOneVariantGroup, ProductInterface $mug, GroupInterface $mugVariantGroup, GroupInterface $otherGroup, GroupTypeInterface $variantType, GroupTypeInterface $groupType)
{
$mug->getGroups()->willReturn([$mugVariantGroup, $otherGroup]);
$mugVariantGroup->getType()->willReturn($variantType);
$otherGroup->getType()->willReturn($groupType);
$variantType->isVariant()->willReturn(true);
$groupType->isVariant()->willReturn(false);
$context->buildViolation(Argument::any())->shouldNotBeCalled();
$this->validate($mug, $onlyOneVariantGroup);
}
示例12: Attribute
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, []]);
}
示例13:
function it_supports_standard_normalization(GroupInterface $variantGroup, GroupTypeInterface $variantGroupType)
{
$variantGroup->getType()->willReturn($variantGroupType);
$variantGroupType->isVariant()->willReturn(false);
$this->supportsNormalization($variantGroup, 'standard')->shouldReturn(false);
$variantGroupType->isVariant()->willReturn(true);
$this->supportsNormalization($variantGroup, 'standard')->shouldReturn(true);
$this->supportsNormalization(new \stdClass(), 'standard')->shouldReturn(false);
$this->supportsNormalization($variantGroup, 'xml')->shouldReturn(false);
$this->supportsNormalization($variantGroup, 'json')->shouldReturn(false);
}
示例14: getMissingAxisCodes
/**
* 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;
}
示例15: FileNotFoundException
function it_throws_an_exception_if_media_of_variant_group_is_not_found($normalizer, $denormalizer, ArrayCollection $productValuesCollection, ArrayCollection $mediaCollection, ProductMediaInterface $media, GroupInterface $variantGroup, ProductTemplateInterface $productTemplate, ProductValueInterface $productValue)
{
$variantGroup->getProductTemplate()->willReturn($productTemplate);
$variantGroup->getCode()->willReturn('my_variant_group');
$productTemplate->getValuesData()->willReturn([$productValue]);
$denormalizer->denormalize([$productValue], 'ProductValue[]', 'json')->willReturn($productValuesCollection);
$productValuesCollection->filter(Argument::cetera())->willReturn($mediaCollection);
$mediaCollection->toArray()->willReturn([$media]);
$normalizer->normalize([$media], 'csv', ['field_name' => 'media', 'prepare_copy' => true, 'identifier' => 'my_variant_group'])->willThrow(new FileNotFoundException('upload/path/img.jpg'));
$this->shouldThrow(new InvalidItemException('The file "upload/path/img.jpg" does not exist', ['item' => 'my_variant_group', 'uploadDirectory' => 'upload/path/']))->duringProcess($variantGroup);
}