6
6
7
7
namespace Magento \Catalog \Test \Unit \Ui \DataProvider \Product \Listing \Collector ;
8
8
9
+ use Magento \Catalog \Api \Data \ProductInterface ;
10
+ use Magento \Catalog \Api \Data \ProductRender \ImageInterface ;
9
11
use Magento \Catalog \Api \Data \ProductRenderInterface ;
12
+ use Magento \Catalog \Helper \Image as ImageHelper ;
13
+ use Magento \Catalog \Helper \ImageFactory ;
10
14
use Magento \Catalog \Model \Product ;
11
- use Magento \Catalog \Api \Data \ProductInterface ;
12
15
use Magento \Catalog \Ui \DataProvider \Product \Listing \Collector \Image ;
13
16
use Magento \Framework \View \DesignInterface ;
17
+ use Magento \Framework \View \DesignLoader ;
14
18
use Magento \Store \Model \StoreManagerInterface ;
15
- use Magento \Catalog \Helper \ImageFactory ;
16
- use Magento \Catalog \Api \Data \ProductRender \ImageInterface ;
17
- use Magento \Catalog \Helper \Image as ImageHelper ;
18
19
19
20
/**
20
21
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -42,8 +43,21 @@ class ImageTest extends \PHPUnit\Framework\TestCase
42
43
/** @var \Magento\Catalog\Api\Data\ProductRender\ImageInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject */
43
44
private $ imageInterfaceFactory ;
44
45
46
+ /** @var DesignLoader|\PHPUnit_Framework_MockObject_MockObject */
47
+ private $ designLoader ;
48
+
49
+ /**
50
+ * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
51
+ */
52
+ protected $ objectManager ;
53
+
54
+ /**
55
+ * @inheritdoc
56
+ */
45
57
public function setUp ()
46
58
{
59
+ $ this ->objectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
60
+
47
61
$ this ->imageFactory = $ this ->getMockBuilder (ImageFactory::class)
48
62
->disableOriginalConstructor ()
49
63
->getMock ();
@@ -60,14 +74,21 @@ public function setUp()
60
74
->getMock ();
61
75
$ this ->storeManager = $ this ->createMock (StoreManagerInterface::class);
62
76
$ this ->design = $ this ->createMock (DesignInterface::class);
63
- $ this ->model = new Image (
64
- $ this ->imageFactory ,
65
- $ this ->state ,
66
- $ this ->storeManager ,
67
- $ this ->design ,
68
- $ this ->imageInterfaceFactory ,
69
- $ this ->imageCodes
70
- );
77
+ $ this ->designLoader = $ this ->createMock (DesignLoader::class);
78
+
79
+ $ this ->model = $ this ->objectManager
80
+ ->getObject (
81
+ Image::class,
82
+ [
83
+ 'imageFactory ' => $ this ->imageFactory ,
84
+ 'state ' => $ this ->state ,
85
+ 'storeManager ' => $ this ->storeManager ,
86
+ 'design ' => $ this ->design ,
87
+ 'imageRenderInfoFactory ' => $ this ->imageInterfaceFactory ,
88
+ 'imageCodes ' => $ this ->imageCodes ,
89
+ 'designLoader ' => $ this ->designLoader ,
90
+ ]
91
+ );
71
92
}
72
93
73
94
public function testGet ()
@@ -165,6 +186,7 @@ public function testEmulateImageCreating()
165
186
$ imageMock ->expects ($ this ->once ())
166
187
->method ('setUrl ' )
167
188
->with ('url ' );
189
+ $ this ->designLoader ->expects ($ this ->once ())->method ('load ' );
168
190
169
191
$ this ->assertEquals (
170
192
$ imageHelperMock ,
0 commit comments