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']]); }