Skip to content

Commit 26354f6

Browse files
committed
magento/graphql-ce#662: Test coverage of USPS shipping method
1 parent eccc7e7 commit 26354f6

File tree

2 files changed

+17
-77
lines changed

2 files changed

+17
-77
lines changed

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

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

dev/tests/api-functional/testsuite/Magento/GraphQl/Usps/SetUspsShippingMethodsOnCartTest.php

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace Magento\GraphQl\Usps;
99

1010
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
11-
use Magento\GraphQl\Quote\GetQuoteShippingAddressIdByReservedQuoteId;
1211
use Magento\Integration\Api\CustomerTokenServiceInterface;
1312
use Magento\TestFramework\Helper\Bootstrap;
1413
use Magento\TestFramework\TestCase\GraphQlAbstract;
@@ -47,7 +46,7 @@ class SetUspsShippingMethodsOnCartTest extends GraphQlAbstract
4746
/**
4847
* Defines carrier label for "USPS" shipping method
4948
*/
50-
const CARRIER_LABEL = 'United States Postal Service';
49+
const CARRIER_TITLE = 'United States Postal Service';
5150

5251
/**
5352
* Defines carrier code for "USPS" shipping method
@@ -64,11 +63,6 @@ class SetUspsShippingMethodsOnCartTest extends GraphQlAbstract
6463
*/
6564
private $getMaskedQuoteIdByReservedOrderId;
6665

67-
/**
68-
* @var GetQuoteShippingAddressIdByReservedQuoteId
69-
*/
70-
private $getQuoteShippingAddressIdByReservedQuoteId;
71-
7266
/**
7367
* @inheritdoc
7468
*/
@@ -77,9 +71,6 @@ protected function setUp()
7771
$objectManager = Bootstrap::getObjectManager();
7872
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
7973
$this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
80-
$this->getQuoteShippingAddressIdByReservedQuoteId = $objectManager->get(
81-
GetQuoteShippingAddressIdByReservedQuoteId::class
82-
);
8374
}
8475

8576
/**
@@ -99,9 +90,8 @@ public function testSetUspsShippingMethod(string $methodCode, string $methodLabe
9990
{
10091
$quoteReservedId = 'test_quote';
10192
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($quoteReservedId);
102-
$shippingAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute($quoteReservedId);
10393

104-
$query = $this->getQuery($maskedQuoteId, $shippingAddressId, self::CARRIER_CODE, $methodCode);
94+
$query = $this->getQuery($maskedQuoteId, self::CARRIER_CODE, $methodCode);
10595
$response = $this->sendRequestWithToken($query);
10696

10797
self::assertArrayHasKey('setShippingMethodsOnCart', $response);
@@ -118,10 +108,13 @@ public function testSetUspsShippingMethod(string $methodCode, string $methodLabe
118108
self::assertArrayHasKey('method_code', $shippingAddress['selected_shipping_method']);
119109
self::assertEquals($methodCode, $shippingAddress['selected_shipping_method']['method_code']);
120110

121-
self::assertArrayHasKey('label', $shippingAddress['selected_shipping_method']);
111+
self::assertArrayHasKey('carrier_title', $shippingAddress['selected_shipping_method']);
112+
self::assertEquals(self::CARRIER_TITLE, $shippingAddress['selected_shipping_method']['carrier_title']);
113+
114+
self::assertArrayHasKey('method_title', $shippingAddress['selected_shipping_method']);
122115
self::assertEquals(
123-
self::CARRIER_LABEL . ' - ' . $methodLabel,
124-
$shippingAddress['selected_shipping_method']['label']
116+
self::CARRIER_TITLE . ' - ' . $methodLabel,
117+
$shippingAddress['selected_shipping_method']['method_title']
125118
);
126119
}
127120

@@ -163,9 +156,8 @@ public function testSetUspsShippingMethodBasedOnCanadaAddress(string $methodCode
163156
{
164157
$quoteReservedId = 'test_quote';
165158
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($quoteReservedId);
166-
$shippingAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute($quoteReservedId);
167159

168-
$query = $this->getQuery($maskedQuoteId, $shippingAddressId, self::CARRIER_CODE, $methodCode);
160+
$query = $this->getQuery($maskedQuoteId, self::CARRIER_CODE, $methodCode);
169161
$response = $this->sendRequestWithToken($query);
170162

171163
self::assertArrayHasKey('setShippingMethodsOnCart', $response);
@@ -182,10 +174,13 @@ public function testSetUspsShippingMethodBasedOnCanadaAddress(string $methodCode
182174
self::assertArrayHasKey('method_code', $shippingAddress['selected_shipping_method']);
183175
self::assertEquals($methodCode, $shippingAddress['selected_shipping_method']['method_code']);
184176

185-
self::assertArrayHasKey('label', $shippingAddress['selected_shipping_method']);
177+
self::assertArrayHasKey('carrier_title', $shippingAddress['selected_shipping_method']);
178+
self::assertEquals(self::CARRIER_TITLE, $shippingAddress['selected_shipping_method']['carrier_title']);
179+
180+
self::assertArrayHasKey('method_title', $shippingAddress['selected_shipping_method']);
186181
self::assertEquals(
187-
self::CARRIER_LABEL . ' - ' . $methodLabel,
188-
$shippingAddress['selected_shipping_method']['label']
182+
self::CARRIER_TITLE . ' - ' . $methodLabel,
183+
$shippingAddress['selected_shipping_method']['method_title']
189184
);
190185
}
191186

@@ -211,15 +206,13 @@ public function dataProviderShippingMethodsBasedOnCanadaAddress(): array
211206
/**
212207
* Generates query for setting the specified shipping method on cart
213208
*
214-
* @param int $shippingAddressId
215209
* @param string $maskedQuoteId
216210
* @param string $carrierCode
217211
* @param string $methodCode
218212
* @return string
219213
*/
220214
private function getQuery(
221215
string $maskedQuoteId,
222-
int $shippingAddressId,
223216
string $carrierCode,
224217
string $methodCode
225218
): string {
@@ -229,7 +222,6 @@ private function getQuery(
229222
cart_id: "$maskedQuoteId"
230223
shipping_methods: [
231224
{
232-
cart_address_id: $shippingAddressId
233225
carrier_code: "$carrierCode"
234226
method_code: "$methodCode"
235227
}
@@ -240,7 +232,8 @@ private function getQuery(
240232
selected_shipping_method {
241233
carrier_code
242234
method_code
243-
label
235+
carrier_title
236+
method_title
244237
}
245238
}
246239
}

0 commit comments

Comments
 (0)