コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getImage($product, $imageId, $attributes = array())
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getImage');
     if (!$pluginInfo) {
         return parent::getImage($product, $imageId, $attributes);
     } else {
         return $this->___callPlugins('getImage', func_get_args(), $pluginInfo);
     }
 }
コード例 #2
0
 public function testGetGalleryImages()
 {
     $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productTypeMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Type\\AbstractType')->disableOriginalConstructor()->getMock();
     $productTypeMock->expects($this->once())->method('getStoreFilter')->with($productMock)->willReturn($storeMock);
     $productMock->expects($this->once())->method('getTypeInstance')->willReturn($productTypeMock);
     $productMock->expects($this->once())->method('getMediaGalleryImages')->willReturn($this->getImagesCollection());
     $this->registry->expects($this->once())->method('registry')->with('product')->willReturn($productMock);
     $this->imageHelper->expects($this->exactly(3))->method('init')->willReturnMap([[$productMock, 'product_page_image_small', [], $this->imageHelper], [$productMock, 'product_page_image_medium', [], $this->imageHelper], [$productMock, 'product_page_image_large', [], $this->imageHelper]])->willReturnSelf();
     $this->imageHelper->expects($this->exactly(3))->method('setImageFile')->with('test_file')->willReturnSelf();
     $this->imageHelper->expects($this->at(0))->method('getUrl')->willReturn('product_page_image_small_url');
     $this->imageHelper->expects($this->at(1))->method('getUrl')->willReturn('product_page_image_medium_url');
     $this->imageHelper->expects($this->at(2))->method('getUrl')->willReturn('product_page_image_large_url');
     $this->imageHelper->expects($this->exactly(2))->method('constrainOnly')->with(true)->willReturnSelf();
     $this->imageHelper->expects($this->exactly(2))->method('keepAspectRatio')->with(true)->willReturnSelf();
     $this->imageHelper->expects($this->exactly(2))->method('keepFrame')->with(false)->willReturnSelf();
     $images = $this->model->getGalleryImages();
     $this->assertInstanceOf('Magento\\Framework\\Data\\Collection', $images);
 }
コード例 #3
0
 /**
  * @param \Magento\Catalog\Block\Product\Context $context
  * @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils
  * @param \Magento\ProductVideo\Helper\Media $mediaHelper
  * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
  * @param array $data
  */
 public function __construct(\Magento\Catalog\Block\Product\Context $context, \Magento\Framework\Stdlib\ArrayUtils $arrayUtils, \Magento\Framework\Json\EncoderInterface $jsonEncoder, \Magento\ProductVideo\Helper\Media $mediaHelper, array $data = [])
 {
     parent::__construct($context, $arrayUtils, $jsonEncoder, $data);
     $this->mediaHelper = $mediaHelper;
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function offsetGet($offset)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'offsetGet');
     if (!$pluginInfo) {
         return parent::offsetGet($offset);
     } else {
         return $this->___callPlugins('offsetGet', func_get_args(), $pluginInfo);
     }
 }