Skip to content

Commit fe708a2

Browse files
committed
Api-functional tests for customer added
1 parent 8515566 commit fe708a2

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,44 @@ public function testGetTotalsFromAnotherCustomerCart()
153153
$this->graphQlQuery($query, [], '', $this->getHeaderMap('customer3@search.example.com'));
154154
}
155155

156+
/**
157+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
158+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/cart_rule_discount_no_coupon.php
159+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
160+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
161+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
162+
*/
163+
public function testGetDiscountInformation()
164+
{
165+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
166+
$query = $this->getQuery($maskedQuoteId);
167+
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
168+
169+
$discountResponse = $response['cart']['prices']['discount'];
170+
self::assertEquals(-10, $discountResponse['amount']['value']);
171+
self::assertEquals('50% Off for all orders', $discountResponse['label']);
172+
}
173+
174+
/**
175+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
176+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/cart_rule_discount_no_coupon.php
177+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
178+
* @magentoApiDataFixture Magento/Checkout/_files/discount_10percent_generalusers.php
179+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
180+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
181+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/apply_coupon.php
182+
*/
183+
public function testGetDiscountInformationWithTwoRulesApplied()
184+
{
185+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
186+
$query = $this->getQuery($maskedQuoteId);
187+
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
188+
189+
$discountResponse = $response['cart']['prices']['discount'];
190+
self::assertEquals(-11, $discountResponse['amount']['value']);
191+
self::assertEquals('50% Off for all orders, Test Coupon for General', $discountResponse['label']);
192+
}
193+
156194
/**
157195
* Generates GraphQl query for retrieving cart totals
158196
*
@@ -188,6 +226,13 @@ private function getQuery(string $maskedQuoteId): string
188226
currency
189227
}
190228
}
229+
discount {
230+
label
231+
amount {
232+
value
233+
currency
234+
}
235+
}
191236
}
192237
}
193238
}

dev/tests/integration/testsuite/Magento/Checkout/_files/discount_10percent_generalusers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
$data = [
1515
'name' => 'Test Coupon for General',
1616
'is_active' => true,
17+
'store_labels' => [0 => 'Test Coupon for General'],
1718
'website_ids' => [
1819
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
1920
\Magento\Store\Model\StoreManagerInterface::class

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
$ruleData = [
3535
'name' => '50% Off for all orders',
3636
'is_active' => 1,
37-
'customer_group_ids' => [CustomerGroupManagement::NOT_LOGGED_IN_ID],
37+
'customer_group_ids' => [CustomerGroupManagement::NOT_LOGGED_IN_ID, 1],
3838
'coupon_type' => RuleData::COUPON_TYPE_NO_COUPON,
3939
'conditions' => [],
4040
'simple_action' => 'by_percent',

0 commit comments

Comments
 (0)