public function it_succesfully_checks_complete_media(ProductValueInterface $value, ChannelInterface $channel, LocaleInterface $locale, ProductMediaInterface $media) { $value->getMedia()->willReturn(null); $this->isComplete($value, $channel, $locale)->shouldReturn(false); $value->getMedia()->willReturn([]); $this->isComplete($value, $channel, $locale)->shouldReturn(false); $media->__toString()->willReturn(''); $value->getMedia()->willReturn($media); $this->isComplete($value, $channel, $locale)->shouldReturn(false); $media->__toString()->willReturn('other'); $value->getMedia()->willReturn($media); $this->isComplete($value, $channel, $locale)->shouldReturn(true); }
function it_returns_flat_data_with_media($serializer, $channelManager, ChannelInterface $channel, ProductInterface $product, ProductMediaInterface $media1, ProductMediaInterface $media2, ProductValueInterface $value1, ProductValueInterface $value2, AttributeInterface $attribute) { $this->setLocale('en_US'); $media1->getFilename()->willReturn('media_name'); $media1->getOriginalFilename()->willReturn('media_original_name'); $media2->getFilename()->willReturn('media_name'); $media2->getOriginalFilename()->willReturn('media_original_name'); $value1->getAttribute()->willReturn($attribute); $value1->getData()->willReturn($media1); $value2->getAttribute()->willReturn($attribute); $value2->getData()->willReturn($media2); $attribute->getAttributeType()->willReturn('pim_catalog_image'); $product->getValues()->willReturn([$value1, $value2]); $serializer->normalize([$media1, $media2], 'flat', ['field_name' => 'media', 'prepare_copy' => true])->willReturn(['normalized_media1', 'normalized_media2']); $serializer->normalize($product, 'flat', ['scopeCode' => 'mobile', 'localeCodes' => '', 'locale' => 'en_US'])->willReturn(['normalized_product']); $channelManager->getChannelByCode('mobile')->willReturn($channel); $this->setChannelCode('mobile'); $this->process($product)->shouldReturn(['media' => ['normalized_media1', 'normalized_media2'], 'product' => ['normalized_product']]); }
function it_marks_product_as_updated_when_a_product_media_is_updated(EntityManager $em, UnitOfWork $uow, ProductInterface $product, ProductValueInterface $value, ProductMediaInterface $media) { $media->getValue()->willReturn($value); $value->getEntity()->willReturn($product); $this->guessUpdates($em, $media, UpdateGuesserInterface::ACTION_UPDATE_ENTITY)->shouldReturn([$product]); }