@@ -190,4 +190,64 @@ public function createDataProvider()
190
190
],
191
191
];
192
192
}
193
+
194
+ /**
195
+ * @param array $data
196
+ * @param array $expected
197
+ * @dataProvider createDataProvider
198
+ */
199
+ public function testCreateWithSimpleProduct ($ data , $ expected )
200
+ {
201
+ $ imageId = 'test_image_id ' ;
202
+
203
+ $ productMock = $ this ->createMock (\Magento \Catalog \Model \Product::class);
204
+ $ simpleOptionMock = $ this ->createMock (\Magento \Wishlist \Model \Item \Option::class);
205
+ $ simpleProductMock = $ this ->createMock (\Magento \Catalog \Model \Product::class);
206
+
207
+ $ productMock ->expects ($ this ->once ())->method ('getCustomOption ' )
208
+ ->with ('simple_product ' )->willReturn ($ simpleOptionMock );
209
+
210
+ $ simpleOptionMock ->expects ($ this ->once ())->method ('getProduct ' )->willReturn ($ simpleProductMock );
211
+
212
+ $ helperMock = $ this ->createMock (\Magento \Catalog \Helper \Image::class);
213
+ $ helperMock ->expects ($ this ->once ())
214
+ ->method ('init ' )
215
+ ->with ($ simpleProductMock , $ imageId )
216
+ ->willReturnSelf ();
217
+ $ helperMock ->expects ($ this ->once ())
218
+ ->method ('getFrame ' )
219
+ ->willReturn ($ data ['frame ' ]);
220
+ $ helperMock ->expects ($ this ->once ())
221
+ ->method ('getUrl ' )
222
+ ->willReturn ($ data ['url ' ]);
223
+ $ helperMock ->expects ($ this ->exactly (2 ))
224
+ ->method ('getWidth ' )
225
+ ->willReturn ($ data ['width ' ]);
226
+ $ helperMock ->expects ($ this ->exactly (2 ))
227
+ ->method ('getHeight ' )
228
+ ->willReturn ($ data ['height ' ]);
229
+ $ helperMock ->expects ($ this ->once ())
230
+ ->method ('getLabel ' )
231
+ ->willReturn ($ data ['label ' ]);
232
+ $ helperMock ->expects ($ this ->once ())
233
+ ->method ('getResizedImageInfo ' )
234
+ ->willReturn ($ data ['imagesize ' ]);
235
+
236
+ $ this ->helperFactory ->expects ($ this ->once ())
237
+ ->method ('create ' )
238
+ ->willReturn ($ helperMock );
239
+
240
+ $ imageMock = $ this ->createMock (\Magento \Catalog \Block \Product \Image::class);
241
+
242
+ $ this ->imageFactory ->expects ($ this ->once ())
243
+ ->method ('create ' )
244
+ ->with ($ expected )
245
+ ->willReturn ($ imageMock );
246
+
247
+ $ this ->model ->setProduct ($ productMock );
248
+ $ this ->model ->setImageId ($ imageId );
249
+ $ this ->model ->setAttributes ($ data ['custom_attributes ' ]);
250
+
251
+ $ this ->assertInstanceOf (\Magento \Catalog \Block \Product \Image::class, $ this ->model ->create ());
252
+ }
193
253
}
0 commit comments