@@ -96,6 +96,16 @@ class CartTest extends \PHPUnit_Framework_TestCase
96
96
*/
97
97
protected $ urlMock ;
98
98
99
+ /**
100
+ * @var \Magento\Checkout\Helper\Cart|\PHPUnit_Framework_MockObject_MockObject
101
+ */
102
+ protected $ cartHelperMock ;
103
+
104
+ /**
105
+ * @var \Magento\Framework\Json\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
106
+ */
107
+ protected $ jsonHelperMock ;
108
+
99
109
/**
100
110
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
101
111
*/
@@ -139,7 +149,7 @@ protected function setUp()
139
149
140
150
$ this ->requestMock = $ this ->getMockBuilder ('Magento\Framework\App\RequestInterface ' )
141
151
->disableOriginalConstructor ()
142
- ->setMethods (['getParams ' , 'getParam ' ])
152
+ ->setMethods (['getParams ' , 'getParam ' , ' isAjax ' ])
143
153
->getMockForAbstractClass ();
144
154
145
155
$ this ->responseMock = $ this ->getMockBuilder ('Magento\Framework\App\ResponseInterface ' )
@@ -187,6 +197,14 @@ protected function setUp()
187
197
->method ('getUrl ' )
188
198
->will ($ this ->returnValue ($ this ->urlMock ));
189
199
200
+ $ this ->cartHelperMock = $ this ->getMockBuilder ('Magento\Checkout\Helper\Cart ' )
201
+ ->disableOriginalConstructor ()
202
+ ->getMock ();
203
+
204
+ $ this ->jsonHelperMock = $ this ->getMockBuilder ('Magento\Framework\Json\Helper\Data ' )
205
+ ->disableOriginalConstructor ()
206
+ ->getMock ();
207
+
190
208
$ this ->model = new Cart (
191
209
$ this ->contextMock ,
192
210
$ this ->wishlistProviderMock ,
@@ -196,7 +214,9 @@ protected function setUp()
196
214
$ this ->optionFactoryMock ,
197
215
$ this ->productHelperMock ,
198
216
$ this ->escaperMock ,
199
- $ this ->helperMock
217
+ $ this ->helperMock ,
218
+ $ this ->cartHelperMock ,
219
+ $ this ->jsonHelperMock
200
220
);
201
221
}
202
222
@@ -397,6 +417,9 @@ public function testExecuteWithQuantityArray()
397
417
$ this ->requestMock ->expects ($ this ->once ())
398
418
->method ('getParams ' )
399
419
->willReturn ($ params );
420
+ $ this ->requestMock ->expects ($ this ->once ())
421
+ ->method ('isAjax ' )
422
+ ->willReturn (false );
400
423
401
424
$ buyRequestMock = $ this ->getMockBuilder ('Magento\Framework\Object ' )
402
425
->disableOriginalConstructor ()
@@ -467,7 +490,7 @@ public function testExecuteWithQuantityArray()
467
490
->with ('You added ' . $ productName . ' to your shopping cart. ' , null )
468
491
->willReturnSelf ();
469
492
470
- $ this ->checkoutCartMock ->expects ($ this ->once ())
493
+ $ this ->cartHelperMock ->expects ($ this ->once ())
471
494
->method ('getShouldRedirectToCart ' )
472
495
->willReturn (false );
473
496
0 commit comments