@@ -308,12 +308,12 @@ public function testGetQuoteWithoutQuoteId()
308
308
* Run test getQuote method
309
309
*
310
310
* @return void
311
+ * @dataProvider getQuoteDataProvider
311
312
*/
312
- public function testGetQuoteWithQuoteId ()
313
+ public function testGetQuoteWithQuoteId ($ customerId , $ quoteCustomerId , $ expectedNumberOfInvokes )
313
314
{
314
315
$ quoteId = 22 ;
315
316
$ storeId = 10 ;
316
- $ customerId = 66 ;
317
317
318
318
$ this ->quote ->expects ($ this ->any ())
319
319
->method ('getQuoteId ' )
@@ -331,7 +331,7 @@ public function testGetQuoteWithQuoteId()
331
331
$ dataCustomerMock = $ this ->getMockBuilder ('Magento\Customer\Api\Data\CustomerInterface ' )
332
332
->disableOriginalConstructor ()
333
333
->getMock ();
334
- $ this ->customerRepositoryMock ->expects ($ this ->once ())
334
+ $ this ->customerRepositoryMock ->expects ($ this ->$ expectedNumberOfInvokes ())
335
335
->method ('getById ' )
336
336
->with ($ customerId )
337
337
->willReturn ($ dataCustomerMock );
@@ -346,6 +346,7 @@ public function testGetQuoteWithQuoteId()
346
346
'assignCustomer ' ,
347
347
'setIgnoreOldQty ' ,
348
348
'setIsSuperMode ' ,
349
+ 'getCustomerId ' ,
349
350
'__wakeup '
350
351
],
351
352
[],
@@ -355,7 +356,7 @@ public function testGetQuoteWithQuoteId()
355
356
$ quoteMock ->expects ($ this ->once ())
356
357
->method ('setStoreId ' )
357
358
->with ($ storeId );
358
- $ quoteMock ->expects ($ this ->once ())
359
+ $ quoteMock ->expects ($ this ->$ expectedNumberOfInvokes ())
359
360
->method ('assignCustomer ' )
360
361
->with ($ dataCustomerMock );
361
362
$ quoteMock ->expects ($ this ->once ())
@@ -364,6 +365,9 @@ public function testGetQuoteWithQuoteId()
364
365
$ quoteMock ->expects ($ this ->once ())
365
366
->method ('setIsSuperMode ' )
366
367
->with (true );
368
+ $ quoteMock ->expects ($ this ->once ())
369
+ ->method ('getCustomerId ' )
370
+ ->will ($ this ->returnValue ($ quoteCustomerId ));
367
371
368
372
$ this ->quoteRepositoryMock ->expects ($ this ->once ())
369
373
->method ('create ' )
@@ -375,4 +379,15 @@ public function testGetQuoteWithQuoteId()
375
379
376
380
$ this ->assertEquals ($ quoteMock , $ this ->quote ->getQuote ());
377
381
}
382
+
383
+ /**
384
+ * @return array
385
+ */
386
+ public function getQuoteDataProvider ()
387
+ {
388
+ return [
389
+ 'customer ids different ' => [66 , null , 'once ' ],
390
+ 'customer ids same ' => [66 , 66 , 'never ' ],
391
+ ];
392
+ }
378
393
}
0 commit comments