|
11 | 11 | use Magento\ConfigurableProduct\Block\Plugin\Product\Media\Gallery;
|
12 | 12 | use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
|
13 | 13 | use Magento\Framework\DataObject;
|
| 14 | +use Magento\Framework\Data\Collection as DataCollection; |
14 | 15 | use Magento\Framework\Serialize\Serializer\Json;
|
15 | 16 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
16 | 17 | use PHPUnit\Framework\MockObject\MockObject;
|
@@ -41,13 +42,20 @@ public function testAfterGetOptions()
|
41 | 42 | ['media_type' => 'type', 'video_url' => 'url', 'file' => 'image.jpg']
|
42 | 43 | );
|
43 | 44 |
|
| 45 | + $dataCollection = $this->getMockBuilder(DataCollection::class) |
| 46 | + ->disableOriginalConstructor() |
| 47 | + ->onlyMethods(['getItems']) |
| 48 | + ->getMock(); |
| 49 | + |
| 50 | + |
44 | 51 | $galleryMock->expects(($this->any()))->method('getProduct')->willReturn($productMock);
|
45 | 52 | $productMock->expects($this->once())->method('getTypeId')->willReturn('configurable');
|
46 | 53 | $productMock->expects($this->once())->method('getTypeInstance')->willReturn($configurableTypeMock);
|
47 | 54 | $configurableTypeMock->expects($this->once())->method('getUsedProducts')->with($productMock)
|
48 | 55 | ->willReturn([$variationProductMock]);
|
49 | 56 | $variationProductMock->expects($this->once())->method('getId')->willReturn($variationProductId);
|
50 |
| - $variationProductMock->expects($this->once())->method('getMediaGalleryImages')->willReturn([$image]); |
| 57 | + $variationProductMock->expects($this->once())->method('getMediaGalleryImages')->willReturn($dataCollection); |
| 58 | + $dataCollection->expects($this->once())->method('getItems')->willReturn([$image]); |
51 | 59 | $variationProductMock->expects($this->once())->method('getImage')->willReturn('image.jpg');
|
52 | 60 | $jsonMock->expects($this->once())->method('serialize')->with($expectedGalleryJson)
|
53 | 61 | ->willReturn(json_encode($expectedGalleryJson));
|
|
0 commit comments