Skip to content

Commit 282dfc5

Browse files
committed
MC-17460: Coupon's expiration date and time do not match staging update end_date after creating a staging update
- Fixed CI build fails
1 parent 2e4d79e commit 282dfc5

File tree

7 files changed

+11
-84
lines changed

7 files changed

+11
-84
lines changed

app/code/Magento/SalesRule/Api/Data/CouponInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public function setUsagePerCustomer($usagePerCustomer);
9999
public function getTimesUsed();
100100

101101
/**
102+
* Set time used.
103+
*
102104
* @param int $timesUsed
103105
* @return $this
104106
*/
@@ -160,6 +162,8 @@ public function setCreatedAt($createdAt);
160162
public function getType();
161163

162164
/**
165+
* Set type of coupon.
166+
*
163167
* @param int $type
164168
* @return $this
165169
*/

app/code/Magento/SalesRule/Model/ResourceModel/Coupon.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public function _beforeSave(AbstractModel $object)
4343
/**
4444
* Load primary coupon (is_primary = 1) for specified rule
4545
*
46-
*
4746
* @param \Magento\SalesRule\Model\Coupon $object
4847
* @param \Magento\SalesRule\Model\Rule|int $rule
4948
* @return bool
49+
* @throws \Magento\Framework\Exception\LocalizedException
5050
*/
5151
public function loadPrimaryByRule(\Magento\SalesRule\Model\Coupon $object, $rule)
5252
{

app/code/Magento/SalesRule/Test/Unit/Model/Coupon/MassgeneratorTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MassgeneratorTest extends \PHPUnit\Framework\TestCase
2323
protected function setUp()
2424
{
2525
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
26-
$this->charset = str_split(md5((string)time()));
26+
$this->charset = str_split(sha1((string)time()));
2727
}
2828

2929
/**
@@ -103,7 +103,9 @@ public function testGeneratePool()
103103
$dateMock = $this->createPartialMock(\Magento\Framework\Stdlib\DateTime\DateTime::class, ['gmtTimestamp']);
104104
$dateTimeMock = $this->createPartialMock(\Magento\Framework\Stdlib\DateTime::class, ['formatDate']);
105105
$couponFactoryMock = $this->createPartialMock(\Magento\SalesRule\Model\CouponFactory::class, ['create']);
106-
$couponMock = $this->createPartialMock(\Magento\SalesRule\Model\Coupon::class, [
106+
$couponMock = $this->createPartialMock(
107+
\Magento\SalesRule\Model\Coupon::class,
108+
[
107109
'__wakeup',
108110
'setId',
109111
'setRuleId',
@@ -113,7 +115,8 @@ public function testGeneratePool()
113115
'setType',
114116
'setCode',
115117
'save'
116-
]);
118+
]
119+
);
117120

118121
$couponMock->expects($this->any())->method('setId')->will($this->returnSelf());
119122
$couponMock->expects($this->any())->method('setRuleId')->will($this->returnSelf());

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/ApplyCouponToCartTest.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,25 +162,6 @@ public function testApplyCouponToNonExistentCart()
162162
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
163163
}
164164

165-
/**
166-
* @magentoApiDataFixture Magento/Checkout/_files/discount_10percent_generalusers.php
167-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
168-
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
169-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
170-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
171-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/make_coupon_expired.php
172-
* @expectedException \Exception
173-
* @expectedExceptionMessage The coupon code isn't valid. Verify the code and try again.
174-
*/
175-
public function testApplyExpiredCoupon()
176-
{
177-
$couponCode = '2?ds5!2d';
178-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
179-
$query = $this->getQuery($maskedQuoteId, $couponCode);
180-
181-
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
182-
}
183-
184165
/**
185166
* Products in cart don't fit to the coupon
186167
*

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,24 +128,6 @@ public function testApplyCouponToNonExistentCart()
128128
$this->graphQlMutation($query);
129129
}
130130

131-
/**
132-
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
133-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
134-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
135-
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
136-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/make_coupon_expired.php
137-
* @expectedException \Exception
138-
* @expectedExceptionMessage The coupon code isn't valid. Verify the code and try again.
139-
*/
140-
public function testApplyExpiredCoupon()
141-
{
142-
$couponCode = '2?ds5!2d';
143-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
144-
$query = $this->getQuery($maskedQuoteId, $couponCode);
145-
146-
$this->graphQlMutation($query);
147-
}
148-
149131
/**
150132
* Products in cart don't fit to the coupon
151133
*

dev/tests/integration/testsuite/Magento/GraphQl/Quote/_files/make_coupon_expired.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/GraphQl/Quote/_files/make_coupon_expired_rollback.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)