public function testGetMediaGalleryEntries()
 {
     $this->setupMediaAttributes();
     $this->model->setData('image', 'imageFile.jpg');
     $this->model->setData('small_image', 'smallImageFile.jpg');
     $mediaEntries = ['images' => [['value_id' => 1, 'file' => 'imageFile.jpg', 'media_type' => 'image'], ['value_id' => 2, 'file' => 'smallImageFile.jpg', 'media_type' => 'image']]];
     $this->model->setData('media_gallery', $mediaEntries);
     $entry1 = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductAttributeMediaGalleryEntryInterface', [], [], '', false);
     $entry2 = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductAttributeMediaGalleryEntryInterface', [], [], '', false);
     $this->converterMock->expects($this->exactly(2))->method('convertTo')->willReturnOnConsecutiveCalls($entry1, $entry2);
     $this->assertEquals([$entry1, $entry2], $this->model->getMediaGalleryEntries());
 }
Example #2
0
 public function testGetMediaGalleryEntries()
 {
     $this->setupMediaAttributes();
     $this->model->setData('image', 'imageFile.jpg');
     $this->model->setData('small_image', 'smallImageFile.jpg');
     $mediaEntries = ['images' => [['value_id' => 1, 'file' => 'imageFile.jpg'], ['value_id' => 2, 'file' => 'smallImageFile.jpg']]];
     $this->model->setData('media_gallery', $mediaEntries);
     $entry1 = $this->getMockBuilder('\\Magento\\Catalog\\Api\\Data\\ProductAttributeMediaGalleryEntryInterface')->setMethods(['setId'])->getMockForAbstractClass();
     $entry1->expects($this->once())->method('setId')->with(1);
     $entry2 = $this->getMockBuilder('\\Magento\\Catalog\\Api\\Data\\ProductAttributeMediaGalleryEntryInterface')->setMethods(['setId'])->getMockForAbstractClass();
     $entry2->expects($this->once())->method('setId')->with(2);
     $this->mediaGalleryEntryFactoryMock->expects($this->at(0))->method('create')->willReturn($entry1);
     $this->mediaGalleryEntryFactoryMock->expects($this->at(1))->method('create')->willReturn($entry2);
     $this->dataObjectHelperMock->expects($this->at(0))->method('populateWithArray')->with($entry1, ['value_id' => 1, 'file' => 'imageFile.jpg', 'types' => ['image']], '\\Magento\\Catalog\\Api\\Data\\ProductAttributeMediaGalleryEntryInterface');
     $this->dataObjectHelperMock->expects($this->at(1))->method('populateWithArray')->with($entry1, ['value_id' => 2, 'file' => 'smallImageFile.jpg', 'types' => ['small_image']], '\\Magento\\Catalog\\Api\\Data\\ProductAttributeMediaGalleryEntryInterface');
     $this->assertEquals([$entry1, $entry2], $this->model->getMediaGalleryEntries());
 }
 /**
  * {@inheritdoc}
  */
 public function getMediaGalleryEntries()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getMediaGalleryEntries');
     if (!$pluginInfo) {
         return parent::getMediaGalleryEntries();
     } else {
         return $this->___callPlugins('getMediaGalleryEntries', func_get_args(), $pluginInfo);
     }
 }