Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 46b40b4

Browse files
committed
Use another fixture for api-functional tests
1 parent 343e463 commit 46b40b4

File tree

3 files changed

+23
-33
lines changed

3 files changed

+23
-33
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ protected function setUp()
4343

4444
/**
4545
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
46-
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_cart_fixed_discount.php
46+
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
4747
*/
4848
public function testApplyCouponToGuestCartWithItems()
4949
{
50-
$couponCode = 'CART_FIXED_DISCOUNT_15';
50+
$couponCode = '2?ds5!2d';
5151

5252
$this->quoteResource->load(
5353
$this->quote,
@@ -64,11 +64,11 @@ public function testApplyCouponToGuestCartWithItems()
6464

6565
/**
6666
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
67-
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_cart_fixed_discount.php
67+
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
6868
*/
6969
public function testApplyCouponTwice()
7070
{
71-
$couponCode = 'CART_FIXED_DISCOUNT_15';
71+
$couponCode = '2?ds5!2d';
7272

7373
$this->quoteResource->load(
7474
$this->quote,
@@ -88,11 +88,11 @@ public function testApplyCouponTwice()
8888

8989
/**
9090
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
91-
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_cart_fixed_discount.php
91+
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
9292
*/
9393
public function testApplyCouponToCartWithNoItems()
9494
{
95-
$couponCode = 'CART_FIXED_DISCOUNT_15';
95+
$couponCode = '2?ds5!2d';
9696

9797
$this->quoteResource->load($this->quote, 'test_order_1', 'reserved_order_id');
9898
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
@@ -104,12 +104,12 @@ public function testApplyCouponToCartWithNoItems()
104104

105105
/**
106106
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
107-
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_cart_fixed_discount.php
107+
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
108108
* @magentoApiDataFixture Magento/Customer/_files/customer.php
109109
*/
110110
public function testGuestCustomerAttemptToChangeCustomerCart()
111111
{
112-
$couponCode = 'CART_FIXED_DISCOUNT_15';
112+
$couponCode = '2?ds5!2d';
113113

114114
$this->quoteResource->load(
115115
$this->quote,
@@ -127,11 +127,11 @@ public function testGuestCustomerAttemptToChangeCustomerCart()
127127

128128
/**
129129
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
130-
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_cart_fixed_discount.php
130+
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
131131
*/
132132
public function testRemoveCoupon()
133133
{
134-
$couponCode = 'CART_FIXED_DISCOUNT_15';
134+
$couponCode = '2?ds5!2d';
135135

136136
/* Apply coupon to the quote */
137137
$this->quoteResource->load(
@@ -158,7 +158,7 @@ public function testRemoveCoupon()
158158

159159
/**
160160
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
161-
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_cart_fixed_discount.php
161+
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
162162
* @magentoApiDataFixture Magento/Customer/_files/customer.php
163163
*/
164164
public function testRemoveCouponFromCustomerCartByGuest()

dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_cart_fixed_discount.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,3 @@
4747
->setCode('CART_FIXED_DISCOUNT_15')
4848
->setType(0);
4949
$objectManager->get(CouponRepositoryInterface::class)->save($coupon);
50-
51-
/** @var Magento\Framework\Registry $registry */
52-
$registry = $objectManager->get(\Magento\Framework\Registry::class);
53-
54-
$registry->unregister('cart_rule_fixed_discount_coupon');
55-
$registry->register('cart_rule_fixed_discount_coupon', $salesRule);

dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_code_with_wildcard_rollback.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,19 @@
1414

1515
$objectManager = Bootstrap::getObjectManager();
1616

17+
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
18+
$searchCriteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class);
19+
$searchCriteria = $searchCriteriaBuilder->addFilter('name', '5$ fixed discount on whole cart')
20+
->create();
21+
22+
/** @var RuleRepositoryInterface $ruleRepository */
23+
$ruleRepository = Bootstrap::getObjectManager()->get(RuleRepositoryInterface::class);
24+
$items = $ruleRepository->getList($searchCriteria)
25+
->getItems();
26+
27+
$salesRule = array_pop($items);
28+
1729
/** @var Rule $salesRule */
18-
$salesRule = getSalesRule('5$ fixed discount on whole cart');
1930
if ($salesRule !== null) {
2031
/** @var RuleRepositoryInterface $ruleRepository */
2132
$ruleRepository = $objectManager->get(RuleRepositoryInterface::class);
@@ -29,18 +40,3 @@
2940
$couponRepository = $objectManager->get(CouponRepositoryInterface::class);
3041
$couponRepository->deleteById($coupon->getCouponId());
3142
}
32-
33-
function getSalesRule(string $name)
34-
{
35-
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
36-
$searchCriteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class);
37-
$searchCriteria = $searchCriteriaBuilder->addFilter('name', $name)
38-
->create();
39-
40-
/** @var RuleRepositoryInterface $ruleRepository */
41-
$ruleRepository = Bootstrap::getObjectManager()->get(RuleRepositoryInterface::class);
42-
$items = $ruleRepository->getList($searchCriteria)
43-
->getItems();
44-
45-
return array_pop($items);
46-
}

0 commit comments

Comments
 (0)