public function testRemove()
 {
     $productSku = 'testProduct';
     $entryId = 42;
     $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)->willReturn($this->productMock);
     $existingEntryMock = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductAttributeMediaGalleryEntryInterface');
     $existingEntryMock->expects($this->once())->method('getId')->willReturn(42);
     $this->productMock->expects($this->once())->method('getMediaGalleryEntries')->willReturn([$existingEntryMock]);
     $this->productMock->expects($this->once())->method('setMediaGalleryEntries')->with([]);
     $this->productRepositoryMock->expects($this->once())->method('save')->with($this->productMock);
     $this->assertTrue($this->model->remove($productSku, $entryId));
 }
 public function testRemove()
 {
     $productSku = 'testProduct';
     $entryId = 42;
     $productMediaGalleryMock = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\AbstractBackend', ['removeImage'], [], '', false);
     $attributeMock = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', [], [], '', false);
     $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)->willReturn($this->productMock);
     $this->productMock->expects($this->once())->method('getTypeInstance')->willReturnSelf();
     $this->productMock->expects($this->once())->method('getSetAttributes')->with($this->productMock)->willReturn(['media_gallery' => $attributeMock]);
     $this->entryResolverMock->expects($this->once())->method('getEntryFilePathById')->with($this->productMock, $entryId)->willReturn('/path');
     $attributeMock->expects($this->once())->method('getBackend')->willReturn($productMediaGalleryMock);
     $productMediaGalleryMock->expects($this->once())->method('removeImage')->with($this->productMock, '/path');
     $this->productRepositoryMock->expects($this->once())->method('save')->with($this->productMock);
     $this->assertTrue($this->model->remove($productSku, $entryId));
 }