Skip to content

Commit 4e2d0aa

Browse files
author
Mike Weis
committed
MAGETWO-31933: Can't change shipping address when creating order in backend
- enhanced unit test
1 parent 834fa8e commit 4e2d0aa

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,12 @@ public function testGetQuoteWithoutQuoteId()
308308
* Run test getQuote method
309309
*
310310
* @return void
311+
* @dataProvider getQuoteDataProvider
311312
*/
312-
public function testGetQuoteWithQuoteId()
313+
public function testGetQuoteWithQuoteId($customerId, $quoteCustomerId, $expectedNumberOfInvokes)
313314
{
314315
$quoteId = 22;
315316
$storeId = 10;
316-
$customerId = 66;
317317

318318
$this->quote->expects($this->any())
319319
->method('getQuoteId')
@@ -331,7 +331,7 @@ public function testGetQuoteWithQuoteId()
331331
$dataCustomerMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')
332332
->disableOriginalConstructor()
333333
->getMock();
334-
$this->customerRepositoryMock->expects($this->once())
334+
$this->customerRepositoryMock->expects($this->$expectedNumberOfInvokes())
335335
->method('getById')
336336
->with($customerId)
337337
->willReturn($dataCustomerMock);
@@ -346,6 +346,7 @@ public function testGetQuoteWithQuoteId()
346346
'assignCustomer',
347347
'setIgnoreOldQty',
348348
'setIsSuperMode',
349+
'getCustomerId',
349350
'__wakeup'
350351
],
351352
[],
@@ -355,7 +356,7 @@ public function testGetQuoteWithQuoteId()
355356
$quoteMock->expects($this->once())
356357
->method('setStoreId')
357358
->with($storeId);
358-
$quoteMock->expects($this->once())
359+
$quoteMock->expects($this->$expectedNumberOfInvokes())
359360
->method('assignCustomer')
360361
->with($dataCustomerMock);
361362
$quoteMock->expects($this->once())
@@ -364,6 +365,9 @@ public function testGetQuoteWithQuoteId()
364365
$quoteMock->expects($this->once())
365366
->method('setIsSuperMode')
366367
->with(true);
368+
$quoteMock->expects($this->once())
369+
->method('getCustomerId')
370+
->will($this->returnValue($quoteCustomerId));
367371

368372
$this->quoteRepositoryMock->expects($this->once())
369373
->method('create')
@@ -375,4 +379,15 @@ public function testGetQuoteWithQuoteId()
375379

376380
$this->assertEquals($quoteMock, $this->quote->getQuote());
377381
}
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+
}
378393
}

0 commit comments

Comments
 (0)