当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductValueInterface::setMedia方法代码示例

本文整理汇总了PHP中Pim\Component\Catalog\Model\ProductValueInterface::setMedia方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductValueInterface::setMedia方法的具体用法?PHP ProductValueInterface::setMedia怎么用?PHP ProductValueInterface::setMedia使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pim\Component\Catalog\Model\ProductValueInterface的用法示例。


在下文中一共展示了ProductValueInterface::setMedia方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 function it_updates_normalized_product_template_values_if_media_values_have_been_handled($normalizer, ProductTemplateInterface $imageTemplate, ProductTemplateInterface $textTemplate, ProductValueInterface $imageValue, ProductValueInterface $textValue, FileInfoInterface $imageMedia)
 {
     $normalizer->normalize(Argument::cetera())->willReturn([]);
     $imageTemplate->getValues()->willReturn([$imageValue]);
     $imageValue->getMedia()->willReturn($imageMedia);
     $imageMedia->isRemoved()->willReturn(true);
     $imageValue->setMedia(null)->shouldBeCalled();
     $imageTemplate->setValuesData([])->shouldBeCalled();
     $textTemplate->getValues()->willReturn([$textValue]);
     $textTemplate->setValuesData([])->shouldNotBeCalled();
     $this->handleProductTemplateMedia($imageTemplate);
     $this->handleProductTemplateMedia($textTemplate);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:13,代码来源:ProductTemplateMediaManagerSpec.php

示例2: DataInvalidItem

 function it_throws_an_exception_if_media_of_variant_group_is_not_found($objectDetacher, $normalizer, $mediaFetcher, $stepExecution, $variantGroupUpdater, ArrayCollection $productValueCollection, FileInfoInterface $media1, FileInfoInterface $media2, GroupInterface $variantGroup, ProductTemplateInterface $productTemplate, ProductValueInterface $productValue1, ProductValueInterface $productValue2, JobParameters $jobParameters, JobExecution $jobExecution, JobInstance $jobInstance, ExecutionContext $executionContext)
 {
     $stepExecution->getJobParameters()->willReturn($jobParameters);
     $jobParameters->get('filePath')->willReturn('my/path/variant_group.csv');
     $jobParameters->has('with_media')->willReturn(true);
     $jobParameters->get('with_media')->willReturn(true);
     $variantGroup->getProductTemplate()->willReturn($productTemplate);
     $variantGroup->getCode()->willReturn('my_variant_group');
     $productValueCollection->toArray()->willReturn([$productValue1, $productValue2]);
     $productValue1->setMedia($media1);
     $productValue2->setMedia($media2);
     $stepExecution->getJobExecution()->willReturn($jobExecution);
     $jobExecution->getJobInstance()->willReturn($jobInstance);
     $jobExecution->getId()->willReturn(100);
     $jobInstance->getCode()->willReturn('csv_variant_group_export');
     $jobExecution->getExecutionContext()->willReturn($executionContext);
     $executionContext->get(JobInterface::WORKING_DIRECTORY_PARAMETER)->willReturn('/working/directory/');
     $values = ['picture' => ['locale' => null, 'scope' => null, 'data' => ['filePath' => 'path/not_found.jpg']]];
     $variantStandard = ['code' => 'my_variant_group', 'values' => $values];
     $normalizer->normalize($variantGroup, null, ['with_variant_group_values' => true, 'identifier' => 'my_variant_group'])->willReturn($variantStandard);
     $variantGroupUpdater->update($variantGroup, ['values' => $variantStandard['values']])->shouldBeCalled();
     $productTemplate->getValuesData()->willReturn($variantStandard['values']);
     $productTemplate->getValues()->willReturn($productValueCollection);
     $mediaFetcher->fetchAll($productValueCollection, '/working/directory/', 'my_variant_group')->shouldBeCalled();
     $mediaFetcher->getErrors()->willReturn([['message' => 'The media has not been found or is not currently available', 'media' => ['filePath' => 'path/not_found.jpg']]]);
     $stepExecution->addWarning('The media has not been found or is not currently available', [], new DataInvalidItem(['filePath' => 'path/not_found.jpg']))->shouldBeCalled();
     $this->process($variantGroup)->shouldReturn($variantStandard);
     $objectDetacher->detach($variantGroup)->shouldBeCalled();
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:29,代码来源:VariantGroupProcessorSpec.php


注:本文中的Pim\Component\Catalog\Model\ProductValueInterface::setMedia方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。