@@ -33,9 +33,9 @@ class QuoteTest extends \PHPUnit_Framework_TestCase
33
33
protected $ cookieManagerMock ;
34
34
35
35
/**
36
- * @var \Magento\Framework\Session\StorageInterface|\PHPUnit_Framework_MockObject_MockObject
36
+ * @var \Magento\Framework\Session\StorageInterface
37
37
*/
38
- protected $ storageMock ;
38
+ protected $ storage ;
39
39
40
40
/**
41
41
* @var \Magento\Framework\Session\ValidatorInterface|\PHPUnit_Framework_MockObject_MockObject
@@ -166,12 +166,7 @@ protected function setUp()
166
166
'' ,
167
167
false
168
168
);
169
- $ this ->storageMock = $ this ->getMockForAbstractClass (
170
- 'Magento\Framework\Session\StorageInterface ' ,
171
- [],
172
- '' ,
173
- false
174
- );
169
+ $ this ->storage = new \Magento \Framework \Session \Storage ();
175
170
$ this ->cookieManagerMock = $ this ->getMock ('Magento\Framework\Stdlib\CookieManagerInterface ' );
176
171
$ this ->cookieMetadataFactoryMock = $ this ->getMock (
177
172
'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory ' ,
@@ -219,7 +214,7 @@ protected function setUp()
219
214
'sessionConfig ' => $ this ->sessionConfigMock ,
220
215
'saveHandler ' => $ this ->saveHandlerMock ,
221
216
'validator ' => $ this ->validatorMock ,
222
- 'storage ' => $ this ->storageMock ,
217
+ 'storage ' => $ this ->storage ,
223
218
'cookieManager ' => $ this ->cookieManagerMock ,
224
219
'cookieMetadataFactory ' => $ this ->cookieMetadataFactoryMock ,
225
220
'appState ' => $ appStateMock ,
@@ -249,20 +244,72 @@ public function testGetQuoteWithoutQuoteId()
249
244
$ customerId = 66 ;
250
245
$ customerGroupId = 77 ;
251
246
252
- $ this ->cartManagementMock ->expects ($ this ->once ())->method ('createEmptyCart ' )->willReturn ($ quoteId );
253
-
254
247
$ this ->quote ->expects ($ this ->any ())
255
248
->method ('getQuoteId ' )
256
249
->will ($ this ->returnValue (null ));
257
250
$ this ->quote ->expects ($ this ->any ())
258
251
->method ('setQuoteId ' )
259
252
->with ($ quoteId );
253
+ $ cartInterfaceMock = $ this ->getMock (
254
+ '\Magento\Quote\Api\Data\CartInterface ' ,
255
+ [
256
+ 'getId ' ,
257
+ 'setId ' ,
258
+ 'getCreatedAt ' ,
259
+ 'setCreatedAt ' ,
260
+ 'getUpdatedAt ' ,
261
+ 'setUpdatedAt ' ,
262
+ 'getConvertedAt ' ,
263
+ 'setConvertedAt ' ,
264
+ 'getIsActive ' ,
265
+ 'setIsActive ' ,
266
+ 'getIsVirtual ' ,
267
+ 'getItems ' ,
268
+ 'setItems ' ,
269
+ 'getItemsCount ' ,
270
+ 'setItemsCount ' ,
271
+ 'getItemsQty ' ,
272
+ 'setItemsQty ' ,
273
+ 'getCustomer ' ,
274
+ 'setCustomer ' ,
275
+ 'getBillingAddress ' ,
276
+ 'setBillingAddress ' ,
277
+ 'getReservedOrderId ' ,
278
+ 'setReservedOrderId ' ,
279
+ 'getOrigOrderId ' ,
280
+ 'setOrigOrderId ' ,
281
+ 'getCurrency ' ,
282
+ 'setCurrency ' ,
283
+ 'getCustomerIsGuest ' ,
284
+ 'setCustomerIsGuest ' ,
285
+ 'getCustomerNote ' ,
286
+ 'setCustomerNote ' ,
287
+ 'getCustomerNoteNotify ' ,
288
+ 'setCustomerNoteNotify ' ,
289
+ 'getCustomerTaxClassId ' ,
290
+ 'setCustomerTaxClassId ' ,
291
+ 'getStoreId ' ,
292
+ 'setStoreId ' ,
293
+ 'getExtensionAttributes ' ,
294
+ 'setExtensionAttributes ' ,
295
+ 'setIgnoreOldQty ' ,
296
+ 'setIsSuperMode ' ,
297
+ 'setCustomerGroupId '
298
+ ]
299
+ );
300
+ $ this ->quoteFactoryMock ->expects ($ this ->once ())
301
+ ->method ('create ' )
302
+ ->willReturn ($ cartInterfaceMock );
260
303
$ this ->quote ->expects ($ this ->any ())
261
304
->method ('getStoreId ' )
262
305
->will ($ this ->returnValue ($ storeId ));
263
306
$ this ->quote ->expects ($ this ->any ())
264
307
->method ('getCustomerId ' )
265
308
->will ($ this ->returnValue ($ customerId ));
309
+ $ cartInterfaceMock ->expects ($ this ->atLeastOnce ())
310
+ ->method ('getId ' )
311
+ ->willReturn ($ quoteId );
312
+
266
313
267
314
$ defaultGroup = $ this ->getMockBuilder ('Magento\Customer\Api\Data\GroupInterface ' )
268
315
->getMock ();
@@ -297,14 +344,10 @@ public function testGetQuoteWithoutQuoteId()
297
344
false
298
345
);
299
346
$ this ->quoteRepositoryMock ->expects ($ this ->once ())->method ('get ' )->willReturn ($ quoteMock );
300
- $ quoteMock ->expects ($ this ->once ())
347
+ $ cartInterfaceMock ->expects ($ this ->once ())
301
348
->method ('setCustomerGroupId ' )
302
349
->with ($ customerGroupId )
303
350
->will ($ this ->returnSelf ());
304
- $ quoteMock ->expects ($ this ->once ())
305
- ->method ('setIsActive ' )
306
- ->with (false )
307
- ->will ($ this ->returnSelf ());
308
351
$ quoteMock ->expects ($ this ->once ())
309
352
->method ('assignCustomer ' )
310
353
->with ($ dataCustomerMock );
0 commit comments