@@ -29,24 +29,16 @@ class ImageBuilderTest extends \PHPUnit\Framework\TestCase
29
29
30
30
protected function setUp ()
31
31
{
32
- $ this ->helperFactory = $ this ->getMockBuilder (\Magento \Catalog \Helper \ImageFactory::class)
33
- ->disableOriginalConstructor ()
34
- ->setMethods (['create ' ])
35
- ->getMock ();
32
+ $ this ->helperFactory = $ this ->createPartialMock (\Magento \Catalog \Helper \ImageFactory::class, ['create ' ]);
36
33
37
- $ this ->imageFactory = $ this ->getMockBuilder (ImageFactory::class)
38
- ->disableOriginalConstructor ()
39
- ->setMethods (['create ' ])
40
- ->getMock ();
34
+ $ this ->imageFactory = $ this ->createPartialMock (ImageFactory::class, ['create ' ]);
41
35
42
36
$ this ->model = new ImageBuilder ($ this ->helperFactory , $ this ->imageFactory );
43
37
}
44
38
45
39
public function testSetProduct ()
46
40
{
47
- $ productMock = $ this ->getMockBuilder (Product::class)
48
- ->disableOriginalConstructor ()
49
- ->getMock ();
41
+ $ productMock = $ this ->createMock (Product::class);
50
42
51
43
$ this ->assertInstanceOf (
52
44
ImageBuilder::class,
@@ -83,13 +75,9 @@ public function testCreate($data, $expected)
83
75
{
84
76
$ imageId = 'test_image_id ' ;
85
77
86
- $ productMock = $ this ->getMockBuilder (Product::class)
87
- ->disableOriginalConstructor ()
88
- ->getMock ();
78
+ $ productMock = $ this ->createMock (Product::class);
89
79
90
- $ helperMock = $ this ->getMockBuilder (Image::class)
91
- ->disableOriginalConstructor ()
92
- ->getMock ();
80
+ $ helperMock = $ this ->createMock (Image::class);
93
81
$ helperMock ->expects ($ this ->once ())
94
82
->method ('init ' )
95
83
->with ($ productMock , $ imageId )
@@ -118,9 +106,7 @@ public function testCreate($data, $expected)
118
106
->method ('create ' )
119
107
->willReturn ($ helperMock );
120
108
121
- $ imageMock = $ this ->getMockBuilder (\Magento \Catalog \Block \Product \Image::class)
122
- ->disableOriginalConstructor ()
123
- ->getMock ();
109
+ $ imageMock = $ this ->createMock (\Magento \Catalog \Block \Product \Image::class);
124
110
125
111
$ this ->imageFactory ->expects ($ this ->once ())
126
112
->method ('create ' )
@@ -144,13 +130,9 @@ public function testCreateMultipleCalls($data)
144
130
145
131
$ imageId = 'test_image_id ' ;
146
132
147
- $ productMock = $ this ->getMockBuilder (Product::class)
148
- ->disableOriginalConstructor ()
149
- ->getMock ();
133
+ $ productMock = $ this ->createMock (Product::class);
150
134
151
- $ helperMock = $ this ->getMockBuilder (Image::class)
152
- ->disableOriginalConstructor ()
153
- ->getMock ();
135
+ $ helperMock = $ this ->createMock (Image::class);
154
136
$ helperMock ->expects ($ this ->exactly (2 ))
155
137
->method ('init ' )
156
138
->with ($ productMock , $ imageId )
@@ -188,9 +170,7 @@ public function testCreateMultipleCalls($data)
188
170
->method ('create ' )
189
171
->willReturn ($ helperMock );
190
172
191
- $ imageMock = $ this ->getMockBuilder (\Magento \Catalog \Block \Product \Image::class)
192
- ->disableOriginalConstructor ()
193
- ->getMock ();
173
+ $ imageMock = $ this ->createMock (\Magento \Catalog \Block \Product \Image::class);
194
174
195
175
$ this ->imageFactory ->expects ($ this ->at (0 ))
196
176
->method ('create ' )
0 commit comments