6
6
namespace Magento \Catalog \Test \Unit \Block \Product ;
7
7
8
8
use Magento \Catalog \Block \Product \Context ;
9
+ use Magento \Framework \Event \ManagerInterface ;
9
10
use Magento \Framework \Pricing \Render ;
11
+ use Magento \Framework \Url \Helper \Data ;
10
12
use Magento \Framework \View \LayoutInterface ;
11
13
12
14
/**
@@ -50,7 +52,7 @@ class ListProductTest extends \PHPUnit_Framework_TestCase
50
52
protected $ typeInstanceMock ;
51
53
52
54
/**
53
- * @var \Magento\Framework\Url\Helper\ Data | \PHPUnit_Framework_MockObject_MockObject
55
+ * @var Data | \PHPUnit_Framework_MockObject_MockObject
54
56
*/
55
57
protected $ urlHelperMock ;
56
58
@@ -74,11 +76,6 @@ class ListProductTest extends \PHPUnit_Framework_TestCase
74
76
*/
75
77
protected $ toolbarMock ;
76
78
77
- /**
78
- * @var LayoutInterface|\PHPUnit_Framework_MockObject_MockObject
79
- */
80
- private $ layout ;
81
-
82
79
/**
83
80
* @var Context|\PHPUnit_Framework_MockObject_MockObject
84
81
*/
@@ -160,28 +157,15 @@ protected function setUp()
160
157
false
161
158
);
162
159
163
- $ this ->urlHelperMock = $ this ->getMockBuilder (\Magento \Framework \Url \Helper \Data::class)
164
- ->disableOriginalConstructor ()->getMock ();
160
+ $ this ->urlHelperMock = $ this ->getMockBuilder (Data::class)->disableOriginalConstructor ()->getMock ();
161
+ $ this ->context = $ this ->getMockBuilder (Context::class)->disableOriginalConstructor ()->getMock ();
162
+ $ this ->renderer = $ this ->getMockBuilder (Render::class)->disableOriginalConstructor ()->getMock ();
163
+ $ eventManager = $ this ->getMockForAbstractClass (ManagerInterface::class, [], '' , false );
165
164
166
- $ this ->layout = $ this ->getMockBuilder (LayoutInterface::class)
167
- ->disableOriginalConstructor ()
168
- ->getMock ();
169
- $ this ->context = $ this ->getMockBuilder (Context::class)
170
- ->disableOriginalConstructor ()
171
- ->getMock ();
172
- $ this ->renderer = $ this ->getMockBuilder (Render::class)
173
- ->disableOriginalConstructor ()
174
- ->getMock ();
175
-
176
- $ this ->context ->expects ($ this ->any ())
177
- ->method ('getRegistry ' )
178
- ->willReturn ($ this ->registryMock );
179
- $ this ->context ->expects ($ this ->any ())
180
- ->method ('getCartHelper ' )
181
- ->willReturn ($ this ->cartHelperMock );
182
- $ this ->context ->expects ($ this ->any ())
183
- ->method ('getLayout ' )
184
- ->willReturn ($ this ->layout );
165
+ $ this ->context ->expects ($ this ->any ())->method ('getRegistry ' )->willReturn ($ this ->registryMock );
166
+ $ this ->context ->expects ($ this ->any ())->method ('getCartHelper ' )->willReturn ($ this ->cartHelperMock );
167
+ $ this ->context ->expects ($ this ->any ())->method ('getLayout ' )->willReturn ($ this ->layoutMock );
168
+ $ this ->context ->expects ($ this ->any ())->method ('getEventManager ' )->willReturn ($ eventManager );
185
169
186
170
$ this ->block = $ objectManager ->getObject (
187
171
\Magento \Catalog \Block \Product \ListProduct::class,
@@ -195,7 +179,6 @@ protected function setUp()
195
179
]
196
180
);
197
181
$ this ->block ->setToolbarBlockName ('mock ' );
198
- $ this ->block ->setLayout ($ this ->layoutMock );
199
182
}
200
183
201
184
protected function tearDown ()
@@ -305,7 +288,7 @@ public function testSetIsProductListFlagOnGetProductPrice()
305
288
->method ('setData ' )
306
289
->with ('is_product_list ' , true )
307
290
->willReturnSelf ();
308
- $ this ->layout ->expects ($ this ->once ())
291
+ $ this ->layoutMock ->expects ($ this ->once ())
309
292
->method ('getBlock ' )
310
293
->with ('product.price.render.default ' )
311
294
->willReturn ($ this ->renderer );
0 commit comments