當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。