Skip to content

Commit d579013

Browse files
author
Serhiy Shkolyarenko
committed
MAGETWO-52385: Order data is not transferred to new order when making Reorder
fixed unit test
1 parent be68e78 commit d579013

File tree

1 file changed

+59
-16
lines changed

1 file changed

+59
-16
lines changed

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

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class QuoteTest extends \PHPUnit_Framework_TestCase
3333
protected $cookieManagerMock;
3434

3535
/**
36-
* @var \Magento\Framework\Session\StorageInterface|\PHPUnit_Framework_MockObject_MockObject
36+
* @var \Magento\Framework\Session\StorageInterface
3737
*/
38-
protected $storageMock;
38+
protected $storage;
3939

4040
/**
4141
* @var \Magento\Framework\Session\ValidatorInterface|\PHPUnit_Framework_MockObject_MockObject
@@ -166,12 +166,7 @@ protected function setUp()
166166
'',
167167
false
168168
);
169-
$this->storageMock = $this->getMockForAbstractClass(
170-
'Magento\Framework\Session\StorageInterface',
171-
[],
172-
'',
173-
false
174-
);
169+
$this->storage = new \Magento\Framework\Session\Storage();
175170
$this->cookieManagerMock = $this->getMock('Magento\Framework\Stdlib\CookieManagerInterface');
176171
$this->cookieMetadataFactoryMock = $this->getMock(
177172
'Magento\Framework\Stdlib\Cookie\CookieMetadataFactory',
@@ -219,7 +214,7 @@ protected function setUp()
219214
'sessionConfig' => $this->sessionConfigMock,
220215
'saveHandler' => $this->saveHandlerMock,
221216
'validator' => $this->validatorMock,
222-
'storage' => $this->storageMock,
217+
'storage' => $this->storage,
223218
'cookieManager' => $this->cookieManagerMock,
224219
'cookieMetadataFactory' => $this->cookieMetadataFactoryMock,
225220
'appState' => $appStateMock,
@@ -249,20 +244,72 @@ public function testGetQuoteWithoutQuoteId()
249244
$customerId = 66;
250245
$customerGroupId = 77;
251246

252-
$this->cartManagementMock->expects($this->once())->method('createEmptyCart')->willReturn($quoteId);
253-
254247
$this->quote->expects($this->any())
255248
->method('getQuoteId')
256249
->will($this->returnValue(null));
257250
$this->quote->expects($this->any())
258251
->method('setQuoteId')
259252
->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);
260303
$this->quote->expects($this->any())
261304
->method('getStoreId')
262305
->will($this->returnValue($storeId));
263306
$this->quote->expects($this->any())
264307
->method('getCustomerId')
265308
->will($this->returnValue($customerId));
309+
$cartInterfaceMock->expects($this->atLeastOnce())
310+
->method('getId')
311+
->willReturn($quoteId);
312+
266313

267314
$defaultGroup = $this->getMockBuilder('Magento\Customer\Api\Data\GroupInterface')
268315
->getMock();
@@ -297,14 +344,10 @@ public function testGetQuoteWithoutQuoteId()
297344
false
298345
);
299346
$this->quoteRepositoryMock->expects($this->once())->method('get')->willReturn($quoteMock);
300-
$quoteMock->expects($this->once())
347+
$cartInterfaceMock->expects($this->once())
301348
->method('setCustomerGroupId')
302349
->with($customerGroupId)
303350
->will($this->returnSelf());
304-
$quoteMock->expects($this->once())
305-
->method('setIsActive')
306-
->with(false)
307-
->will($this->returnSelf());
308351
$quoteMock->expects($this->once())
309352
->method('assignCustomer')
310353
->with($dataCustomerMock);

0 commit comments

Comments
 (0)