Skip to content

Commit 6b0058a

Browse files
author
Bryant Luk
committed
MAGETWO-36427: Magento\Quote\Api\GuestShippingMethodManagement
- Fix unit tests to use GuestCartTestHelper
1 parent 9dbffdb commit 6b0058a

File tree

2 files changed

+19
-31
lines changed

2 files changed

+19
-31
lines changed

app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTotalRepositoryTest.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,22 @@ public function setUp()
5757
->disableOriginalConstructor()
5858
->getMock();
5959

60+
$this->maskedCartId = 'f216207248d65c789b17be8545e0aa73';
61+
$this->cartId = 123;
62+
63+
$guestCartTestHelper = new GuestCartTestHelper($this);
64+
list($this->quoteIdMaskFactoryMock, $this->quoteIdMaskMock) = $guestCartTestHelper->mockQuoteIdMask(
65+
$this->maskedCartId,
66+
$this->cartId
67+
);
68+
6069
$this->model = $this->objectManager->getObject(
6170
'Magento\Quote\Model\GuestCart\GuestCartTotalRepository',
6271
[
6372
'cartTotalRepository' => $this->cartTotalRepository,
6473
'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock,
6574
]
6675
);
67-
68-
$this->quoteIdMaskFactoryMock->expects($this->once())
69-
->method('create')
70-
->willReturn($this->quoteIdMaskMock);
71-
$this->quoteIdMaskMock->expects($this->once())
72-
->method('load')
73-
->with($this->maskedCartId, 'masked_id')
74-
->willReturn($this->quoteIdMaskMock);
75-
$this->quoteIdMaskMock->expects($this->once())
76-
->method('getId')
77-
->willReturn($this->cartId);
7876
}
7977

8078
public function testGetTotals()

app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingMethodManagementTest.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,23 @@ protected function setUp()
4646
$this->shippingMethodManagementMock =
4747
$this->getMockBuilder('Magento\Quote\Api\ShippingMethodManagementInterface')
4848
->getMockForAbstractClass();
49-
$this->quoteIdMaskFactoryMock = $this->getMockBuilder('Magento\Quote\Model\QuoteIdMaskFactory')
50-
->disableOriginalConstructor()
51-
->getMock();
52-
$this->quoteIdMaskMock = $this->getMockBuilder('Magento\Quote\Model\QuoteIdMask')
53-
->disableOriginalConstructor()
54-
->getMock();
49+
50+
$this->maskedCartId = 'f216207248d65c789b17be8545e0aa73';
51+
$this->cartId = 867;
52+
53+
$guestCartTestHelper = new GuestCartTestHelper($this);
54+
list($this->quoteIdMaskFactoryMock, $this->quoteIdMaskMock) = $guestCartTestHelper->mockQuoteIdMask(
55+
$this->maskedCartId,
56+
$this->cartId
57+
);
58+
5559
$this->model = $objectManager->getObject(
5660
'Magento\Quote\Model\GuestCart\GuestShippingMethodManagement',
5761
[
5862
'shippingMethodManagement' => $this->shippingMethodManagementMock,
5963
'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock,
6064
]
6165
);
62-
63-
$this->maskedCartId = 'f216207248d65c789b17be8545e0aa73';
64-
$this->cartId = 867;
65-
66-
$this->quoteIdMaskFactoryMock->expects($this->once())
67-
->method('create')
68-
->willReturn($this->quoteIdMaskMock);
69-
$this->quoteIdMaskMock->expects($this->once())
70-
->method('load')
71-
->with($this->maskedCartId, 'masked_id')
72-
->willReturn($this->quoteIdMaskMock);
73-
$this->quoteIdMaskMock->expects($this->once())
74-
->method('getId')
75-
->willReturn($this->cartId);
7666
}
7767

7868
public function testSet()

0 commit comments

Comments
 (0)