Skip to content

Commit 9e3b6bc

Browse files
committed
magento/graphql-ce#283: [Shipping methods] Support of FedEx shipping method
1 parent 9d489a5 commit 9e3b6bc

File tree

1 file changed

+72
-2
lines changed

1 file changed

+72
-2
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/FedEx/SetFedExShippingMethodsOnCartTest.php

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,19 @@
1515

1616
/**
1717
* Test for setting "FedEx" shipping method on cart
18-
* | Code | Label
18+
*
19+
* | Code | Label
1920
* --------------------------------------
20-
* | FEDEX_GROUND | Ground
21+
* | FEDEX_GROUND | Ground
22+
* | SMART_POST | Smart Post
23+
* | FEDEX_EXPRESS_SAVER | Express Saver
24+
* | PRIORITY_OVERNIGHT | Priority Overnight
25+
* | FEDEX_2_DAY | 2 Day
26+
* | FIRST_OVERNIGHT | First Overnight
27+
* | INTERNATIONAL_ECONOMY |International Economy
28+
* | INTERNATIONAL_PRIORITY | International Priority
29+
*
30+
* This class does not cover another FedEx shipping methods (they depends on address and sandbox settings)
2131
*/
2232
class SetFedExShippingMethodsOnCartTest extends GraphQlAbstract
2333
{
@@ -109,6 +119,66 @@ public function dataProviderShippingMethods(): array
109119
{
110120
return [
111121
'Ground' => ['FEDEX_GROUND', 'Ground'],
122+
'Smart Post' => ['SMART_POST', 'Smart Post'],
123+
'Express Saver' => ['FEDEX_EXPRESS_SAVER', 'Express Saver'],
124+
'Priority Overnight' => ['PRIORITY_OVERNIGHT', 'Priority Overnight'],
125+
'2 Day' => ['FEDEX_2_DAY', '2 Day'],
126+
'First Overnight' => ['FIRST_OVERNIGHT', 'First Overnight'],
127+
];
128+
}
129+
130+
/**
131+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
132+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
133+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/set_weight_to_simple_product.php
134+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
135+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
136+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_canada_address.php
137+
* @magentoApiDataFixture Magento/GraphQl/FedEx/_files/enable_fedex_shipping_method.php
138+
*
139+
* @dataProvider dataProviderShippingMethodsBasedOnCanadaAddress
140+
* @param string $methodCode
141+
* @param string $methodLabel
142+
*/
143+
public function testSetFedExShippingMethodBasedOnCanadaAddress(string $methodCode, string $methodLabel)
144+
{
145+
$quoteReservedId = 'test_quote';
146+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($quoteReservedId);
147+
$shippingAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute($quoteReservedId);
148+
149+
$query = $this->getQuery($maskedQuoteId, $shippingAddressId, self::CARRIER_CODE, $methodCode);
150+
$response = $this->sendRequestWithToken($query);
151+
152+
self::assertArrayHasKey('setShippingMethodsOnCart', $response);
153+
self::assertArrayHasKey('cart', $response['setShippingMethodsOnCart']);
154+
self::assertArrayHasKey('shipping_addresses', $response['setShippingMethodsOnCart']['cart']);
155+
self::assertCount(1, $response['setShippingMethodsOnCart']['cart']['shipping_addresses']);
156+
157+
$shippingAddress = current($response['setShippingMethodsOnCart']['cart']['shipping_addresses']);
158+
self::assertArrayHasKey('selected_shipping_method', $shippingAddress);
159+
160+
self::assertArrayHasKey('carrier_code', $shippingAddress['selected_shipping_method']);
161+
self::assertEquals(self::CARRIER_CODE, $shippingAddress['selected_shipping_method']['carrier_code']);
162+
163+
self::assertArrayHasKey('method_code', $shippingAddress['selected_shipping_method']);
164+
self::assertEquals($methodCode, $shippingAddress['selected_shipping_method']['method_code']);
165+
166+
self::assertArrayHasKey('label', $shippingAddress['selected_shipping_method']);
167+
self::assertEquals(
168+
self::CARRIER_LABEL . ' - ' . $methodLabel,
169+
$shippingAddress['selected_shipping_method']['label']
170+
);
171+
}
172+
173+
/**
174+
* @return array
175+
*/
176+
public function dataProviderShippingMethodsBasedOnCanadaAddress(): array
177+
{
178+
return [
179+
'Ground' => ['FEDEX_GROUND', 'Ground'],
180+
'International Economy' => ['INTERNATIONAL_ECONOMY', 'International Economy'],
181+
'International Priority' => ['INTERNATIONAL_PRIORITY', 'International Priority'],
112182
];
113183
}
114184

0 commit comments

Comments
 (0)