Skip to content

Commit 78f02fa

Browse files
committed
magento/graphql-ce#540: Replace deprecated fixture
1 parent 17ca1ef commit 78f02fa

File tree

1 file changed

+124
-36
lines changed

1 file changed

+124
-36
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php

Lines changed: 124 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,21 @@ protected function setUp()
5555
}
5656

5757
/**
58+
* Set "Next Day Air Early AM" UPS shipping method
59+
*
5860
* @magentoApiDataFixture Magento/Customer/_files/customer.php
59-
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
61+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
6062
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
6163
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
6264
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
6365
* @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php
64-
*
65-
* @param string $carrierMethodCode
66-
* @param string $carrierMethodLabel
67-
* @dataProvider availableForCartShippingMethods
6866
*/
69-
public function testSetAvailableForCartUpsShippingMethod(string $carrierMethodCode, string $carrierMethodLabel)
67+
public function testSetNextDayAirEarlyAmUpsShippingMethod()
7068
{
7169
$quoteReservedId = 'test_quote';
70+
$carrierMethodCode = '1DM';
71+
$carrierMethodLabel = 'Next Day Air Early AM';
72+
7273
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($quoteReservedId);
7374
$shippingAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute($quoteReservedId);
7475

@@ -91,20 +92,21 @@ public function testSetAvailableForCartUpsShippingMethod(string $carrierMethodCo
9192
}
9293

9394
/**
95+
* Set "Next Day Air" UPS shipping method
96+
*
9497
* @magentoApiDataFixture Magento/Customer/_files/customer.php
95-
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
98+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
9699
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
97100
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
98101
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
99102
* @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php
100-
*
101-
* @param string $carrierMethodCode
102-
* @param string $carrierMethodLabel
103-
* @dataProvider notAvailableForCartShippingMethods
104103
*/
105-
public function testSetNotAvailableForCartUpsShippingMethod(string $carrierMethodCode, string $carrierMethodLabel)
104+
public function testSetNextDayAirUpsShippingMethod()
106105
{
107106
$quoteReservedId = 'test_quote';
107+
$carrierMethodCode = '1DA';
108+
$carrierMethodLabel = 'Next Day Air';
109+
108110
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($quoteReservedId);
109111
$shippingAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute($quoteReservedId);
110112

@@ -115,8 +117,41 @@ public function testSetNotAvailableForCartUpsShippingMethod(string $carrierMetho
115117
$carrierMethodCode
116118
);
117119

118-
$this->expectExceptionMessage(
119-
"GraphQL response contains errors: Carrier with such method not found: " . self::CARRIER_CODE . ", " . $carrierMethodCode
120+
$response = $this->sendRequestWithToken($query);
121+
122+
$addressesInformation = $response['setShippingMethodsOnCart']['cart']['shipping_addresses'];
123+
$expectedResult = [
124+
'carrier_code' => self::CARRIER_CODE,
125+
'method_code' => $carrierMethodCode,
126+
'label' => self::CARRIER_LABEL . ' - ' . $carrierMethodLabel,
127+
];
128+
self::assertEquals($addressesInformation[0]['selected_shipping_method'], $expectedResult);
129+
}
130+
131+
/**
132+
* Set "2nd Day Air" UPS shipping method
133+
*
134+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
135+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
136+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
137+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
138+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
139+
* @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php
140+
*/
141+
public function testSet2ndDayAirUpsShippingMethod()
142+
{
143+
$quoteReservedId = 'test_quote';
144+
$carrierMethodCode = '2DA';
145+
$carrierMethodLabel = '2nd Day Air';
146+
147+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($quoteReservedId);
148+
$shippingAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute($quoteReservedId);
149+
150+
$query = $this->getQuery(
151+
$maskedQuoteId,
152+
$shippingAddressId,
153+
self::CARRIER_CODE,
154+
$carrierMethodCode
120155
);
121156

122157
$response = $this->sendRequestWithToken($query);
@@ -131,56 +166,109 @@ public function testSetNotAvailableForCartUpsShippingMethod(string $carrierMetho
131166
}
132167

133168
/**
134-
* @return array
169+
* Set "3 Day Select" UPS shipping method
170+
*
171+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
172+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
173+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
174+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
175+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
176+
* @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php
135177
*/
136-
public function availableForCartShippingMethods(): array
178+
public function testSet3DaySelectUpsShippingMethod()
137179
{
138-
$shippingMethods = ['1DM', '1DA', '2DA', '3DS', 'GND'];
180+
$quoteReservedId = 'test_quote';
181+
$carrierMethodCode = '3DS';
182+
$carrierMethodLabel = '3 Day Select';
139183

140-
return $this->filterShippingMethodsByCodes($shippingMethods);
184+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($quoteReservedId);
185+
$shippingAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute($quoteReservedId);
186+
187+
$query = $this->getQuery(
188+
$maskedQuoteId,
189+
$shippingAddressId,
190+
self::CARRIER_CODE,
191+
$carrierMethodCode
192+
);
193+
194+
$response = $this->sendRequestWithToken($query);
195+
196+
$addressesInformation = $response['setShippingMethodsOnCart']['cart']['shipping_addresses'];
197+
$expectedResult = [
198+
'carrier_code' => self::CARRIER_CODE,
199+
'method_code' => $carrierMethodCode,
200+
'label' => self::CARRIER_LABEL . ' - ' . $carrierMethodLabel,
201+
];
202+
self::assertEquals($addressesInformation[0]['selected_shipping_method'], $expectedResult);
141203
}
142204

143205
/**
144-
* @return array
206+
* Set "Ground" UPS shipping method
207+
*
208+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
209+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
210+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
211+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
212+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
213+
* @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php
145214
*/
146-
public function notAvailableForCartShippingMethods(): array
215+
public function testSetGroundUpsShippingMethod()
147216
{
148-
$shippingMethods = ['1DML', '1DAL', '1DAPI', '1DP', '1DPL', '2DM', '2DML', '2DAL', 'GNDCOM', 'GNDRES', 'STD', 'XPR', 'WXS', 'XPRL', 'XDM', 'XDML', 'XPD'];
217+
$quoteReservedId = 'test_quote';
218+
$carrierMethodCode = 'GND';
219+
$carrierMethodLabel = 'Ground';
149220

150-
return $this->filterShippingMethodsByCodes($shippingMethods);
221+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($quoteReservedId);
222+
$shippingAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute($quoteReservedId);
223+
224+
$query = $this->getQuery(
225+
$maskedQuoteId,
226+
$shippingAddressId,
227+
self::CARRIER_CODE,
228+
$carrierMethodCode
229+
);
230+
231+
$response = $this->sendRequestWithToken($query);
232+
233+
$addressesInformation = $response['setShippingMethodsOnCart']['cart']['shipping_addresses'];
234+
$expectedResult = [
235+
'carrier_code' => self::CARRIER_CODE,
236+
'method_code' => $carrierMethodCode,
237+
'label' => self::CARRIER_LABEL . ' - ' . $carrierMethodLabel,
238+
];
239+
self::assertEquals($addressesInformation[0]['selected_shipping_method'], $expectedResult);
151240
}
152241

242+
243+
244+
245+
153246
/**
154-
* @param array $filter
155247
* @return array
156248
*/
157-
private function filterShippingMethodsByCodes(array $filter):array
249+
public function notAvailableForCartShippingMethods(): array
158250
{
159-
$result = [];
160-
foreach ($this->getAllUpsShippingMethods() as $shippingMethod) {
161-
if (in_array($shippingMethod[0], $filter)) {
162-
$result[] = $shippingMethod;
163-
}
164-
}
165-
return $result;
251+
$shippingMethods = ['1DML', '1DAL', '1DAPI', '1DP', '1DPL', '2DM', '2DML', '2DAL', 'GNDCOM', 'GNDRES', 'STD', 'XPR', 'WXS', 'XPRL', 'XDM', 'XDML', 'XPD'];
252+
253+
return $this->filterShippingMethodsByCodes($shippingMethods);
166254
}
167255

168256
private function getAllUpsShippingMethods():array
169257
{
170258
return [
171-
['1DM', 'Next Day Air Early AM'],
259+
['1DM', 'Next Day Air Early AM'], //
172260
['1DML', 'Next Day Air Early AM Letter'],
173-
['1DA', 'Next Day Air'],
261+
['1DA', 'Next Day Air'], //
174262
['1DAL', 'Next Day Air Letter'],
175263
['1DAPI', 'Next Day Air Intra (Puerto Rico)'],
176264
['1DP', 'Next Day Air Saver'],
177265
['1DPL', 'Next Day Air Saver Letter'],
178266
['2DM', '2nd Day Air AM'],
179267
['2DML', '2nd Day Air AM Letter'],
180-
['2DA', '2nd Day Air'],
268+
['2DA', '2nd Day Air'], //
181269
['2DAL', '2nd Day Air Letter'],
182-
['3DS', '3 Day Select'],
183-
['GND', 'Ground'],
270+
['3DS', '3 Day Select'], //
271+
['GND', 'Ground'], //
184272
['GNDCOM', 'Ground Commercial'],
185273
['GNDRES', 'Ground Residential'],
186274
['STD', 'Canada Standard'],

0 commit comments

Comments
 (0)