/** * @param ProductMediaInterface $media */ protected function copyMedia(ProductMediaInterface $media) { $result = $this->mediaManager->copy($media, dirname($this->getPath())); if ($result === true) { $exportPath = $this->mediaManager->getExportPath($media); $this->writtenFiles[sprintf('%s/%s', dirname($this->getPath()), $exportPath)] = $exportPath; } }
/** * {@inheritdoc} */ protected function doNormalize($object, $format = null, array $context = array()) { $context = $this->resolveContext($context); if ($context['versioning']) { return $object->getFilename(); } return $this->manager->getExportPath($object); }
/** * @param string $locale * @param string $scope * @param string $exportPath * * @dataProvider getExportPathData */ public function testGetExportPath($locale, $scope, $exportPath) { $media = $this->getMediaMock(); $entity = $this->getProductMock('sku000'); $attribute = $this->getAttributeMock('mockFile', $locale !== '', $scope !== ''); $value = $this->getValueMock($entity, $attribute, $locale, $scope); $media->expects($this->any())->method('getValue')->will($this->returnValue($value)); $media->expects($this->any())->method('getOriginalFilename')->will($this->returnValue('phpunit-file.txt')); $media->expects($this->any())->method('getFilePath')->will($this->returnValue('filePath')); $this->assertEquals($exportPath, $this->manager->getExportPath($media)); }