Skip to content

Commit 8b7bb58

Browse files
author
mdykas
committed
issue/14056 - Coupon API not working for guest user - adjusted unit tests
1 parent 6ad9c03 commit 8b7bb58

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ protected function setUp()
4949
'save',
5050
'getShippingAddress',
5151
'getCouponCode',
52+
'getStoreId',
5253
'__wakeup'
5354
]);
5455
$this->quoteAddressMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Address::class, [
@@ -100,6 +101,9 @@ public function testSetWhenCouldNotApplyCoupon()
100101
$cartId = 33;
101102
$couponCode = '153a-ABC';
102103

104+
$this->storeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
105+
$this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($this->returnValue(1));
106+
103107
$this->quoteRepositoryMock->expects($this->once())
104108
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
105109
$this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12));
@@ -127,6 +131,9 @@ public function testSetWhenCouponCodeIsInvalid()
127131
$cartId = 33;
128132
$couponCode = '153a-ABC';
129133

134+
$this->storeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
135+
$this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($this->returnValue(1));
136+
130137
$this->quoteRepositoryMock->expects($this->once())
131138
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
132139
$this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12));
@@ -146,6 +153,9 @@ public function testSet()
146153
$cartId = 33;
147154
$couponCode = '153a-ABC';
148155

156+
$this->storeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
157+
$this->quoteMock->expects($this->once())->method('getStoreId')->willReturn($this->returnValue(1));
158+
149159
$this->quoteRepositoryMock->expects($this->once())
150160
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
151161
$this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12));

0 commit comments

Comments
 (0)