Skip to content

Commit ef9b7b5

Browse files
committed
MAGETWO-52385: Order data is not transferred to new order when making Reorder
1 parent d1d8769 commit ef9b7b5

File tree

3 files changed

+38
-24
lines changed

3 files changed

+38
-24
lines changed

app/code/Magento/Backend/Model/Session/Quote.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function __construct(
150150
*/
151151
public function getQuote()
152152
{
153-
$cartManagement = $this->getCartManagementDependency();
153+
$cartManagement = $this->getCartManagement();
154154

155155
if ($this->_quote === null) {
156156
if ($this->getStoreId()) {
@@ -180,7 +180,7 @@ public function getQuote()
180180
* @return CartManagementInterface
181181
* @deprecated
182182
*/
183-
private function getCartManagementDependency()
183+
private function getCartManagement()
184184
{
185185
if ($this->cartManagement === null) {
186186
$this->cartManagement = ObjectManager::getInstance()->get(CartManagementInterface::class);

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

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ class QuoteTest extends \PHPUnit_Framework_TestCase
9292
*/
9393
protected $quoteFactoryMock;
9494

95+
/**
96+
* @var \PHPUnit_Framework_MockObject_MockObject
97+
*/
98+
protected $cartManagementMock;
99+
95100
/**
96101
* Set up
97102
*
@@ -197,9 +202,16 @@ protected function setUp()
197202
);
198203

199204
$this->quoteFactoryMock = $this->getMock('\Magento\Quote\Model\QuoteFactory', ['create'], [], '', false);
205+
$this->cartManagementMock = $this->getMock(
206+
\Magento\Quote\Api\CartManagementInterface::class,
207+
[],
208+
[],
209+
'',
210+
false
211+
);
200212

201213
$this->quote = $this->getMock(
202-
'Magento\Backend\Model\Session\Quote',
214+
\Magento\Backend\Model\Session\Quote::class,
203215
['getStoreId', 'getQuoteId', 'setQuoteId', 'hasCustomerId', 'getCustomerId'],
204216
[
205217
'request' => $this->requestMock,
@@ -217,10 +229,12 @@ protected function setUp()
217229
'storeManager' => $this->storeManagerMock,
218230
'groupManagement' => $this->groupManagementMock,
219231
'quoteFactory' => $this->quoteFactoryMock
220-
],
221-
'',
222-
true
232+
]
223233
);
234+
235+
$this->prepareObjectManager([
236+
[\Magento\Quote\Api\CartManagementInterface::class, $this->cartManagementMock]
237+
]);
224238
}
225239

226240
/**
@@ -235,6 +249,8 @@ public function testGetQuoteWithoutQuoteId()
235249
$customerId = 66;
236250
$customerGroupId = 77;
237251

252+
$this->cartManagementMock->expects($this->once())->method('createEmptyCart')->willReturn($quoteId);
253+
238254
$this->quote->expects($this->any())
239255
->method('getQuoteId')
240256
->will($this->returnValue(null));
@@ -271,7 +287,6 @@ public function testGetQuoteWithoutQuoteId()
271287
'setStoreId',
272288
'setCustomerGroupId',
273289
'setIsActive',
274-
'getId',
275290
'assignCustomer',
276291
'setIgnoreOldQty',
277292
'setIsSuperMode',
@@ -281,9 +296,7 @@ public function testGetQuoteWithoutQuoteId()
281296
'',
282297
false
283298
);
284-
$quoteMock->expects($this->once())
285-
->method('setStoreId')
286-
->with($storeId);
299+
$this->quoteRepositoryMock->expects($this->once())->method('get')->willReturn($quoteMock);
287300
$quoteMock->expects($this->once())
288301
->method('setCustomerGroupId')
289302
->with($customerGroupId)
@@ -292,9 +305,6 @@ public function testGetQuoteWithoutQuoteId()
292305
->method('setIsActive')
293306
->with(false)
294307
->will($this->returnSelf());
295-
$quoteMock->expects($this->once())
296-
->method('getId')
297-
->will($this->returnValue($quoteId));
298308
$quoteMock->expects($this->once())
299309
->method('assignCustomer')
300310
->with($dataCustomerMock);
@@ -305,13 +315,6 @@ public function testGetQuoteWithoutQuoteId()
305315
->method('setIsSuperMode')
306316
->with(true);
307317

308-
$this->quoteFactoryMock->expects($this->once())
309-
->method('create')
310-
->will($this->returnValue($quoteMock));
311-
$this->quoteRepositoryMock->expects($this->once())
312-
->method('save')
313-
->with($quoteMock);
314-
315318
$this->assertEquals($quoteMock, $this->quote->getQuote());
316319
}
317320

@@ -380,9 +383,6 @@ public function testGetQuoteWithQuoteId($customerId, $quoteCustomerId, $expected
380383
->method('getCustomerId')
381384
->will($this->returnValue($quoteCustomerId));
382385

383-
$this->quoteFactoryMock->expects($this->once())
384-
->method('create')
385-
->will($this->returnValue($quoteMock));
386386
$this->quoteRepositoryMock->expects($this->once())
387387
->method('get')
388388
->with($quoteId)
@@ -401,4 +401,19 @@ public function getQuoteDataProvider()
401401
'customer ids same' => [66, 66, 'never'],
402402
];
403403
}
404+
405+
/**
406+
* @param array $map
407+
* @deprecated
408+
*/
409+
private function prepareObjectManager($map)
410+
{
411+
$objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface');
412+
$objectManagerMock->expects($this->any())->method('getInstance')->willReturnSelf();
413+
$objectManagerMock->expects($this->any())->method('get')->will($this->returnValueMap($map));
414+
$reflectionClass = new \ReflectionClass('Magento\Framework\App\ObjectManager');
415+
$reflectionProperty = $reflectionClass->getProperty('_instance');
416+
$reflectionProperty->setAccessible(true);
417+
$reflectionProperty->setValue($objectManagerMock);
418+
}
404419
}

app/code/Magento/Quote/Test/Unit/Model/QuoteRepository/SaveHandlerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ public function testSaveForVirtualQuote()
120120
->willReturn($this->itemMock);
121121
$this->quoteMock->expects($this->once())->method('setLastAddedItem')->with($this->itemMock);
122122
$this->quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($this->billingAddressMock);
123-
$this->quoteMock->expects($this->exactly(2))->method('getIsActive')->willReturn(true);
124123
$this->billingAddressPersister
125124
->expects($this->once())
126125
->method('save')

0 commit comments

Comments
 (0)