8
8
namespace Magento \GraphQl \Usps ;
9
9
10
10
use Magento \GraphQl \Quote \GetMaskedQuoteIdByReservedOrderId ;
11
- use Magento \GraphQl \Quote \GetQuoteShippingAddressIdByReservedQuoteId ;
12
11
use Magento \Integration \Api \CustomerTokenServiceInterface ;
13
12
use Magento \TestFramework \Helper \Bootstrap ;
14
13
use Magento \TestFramework \TestCase \GraphQlAbstract ;
@@ -47,7 +46,7 @@ class SetUspsShippingMethodsOnCartTest extends GraphQlAbstract
47
46
/**
48
47
* Defines carrier label for "USPS" shipping method
49
48
*/
50
- const CARRIER_LABEL = 'United States Postal Service ' ;
49
+ const CARRIER_TITLE = 'United States Postal Service ' ;
51
50
52
51
/**
53
52
* Defines carrier code for "USPS" shipping method
@@ -64,11 +63,6 @@ class SetUspsShippingMethodsOnCartTest extends GraphQlAbstract
64
63
*/
65
64
private $ getMaskedQuoteIdByReservedOrderId ;
66
65
67
- /**
68
- * @var GetQuoteShippingAddressIdByReservedQuoteId
69
- */
70
- private $ getQuoteShippingAddressIdByReservedQuoteId ;
71
-
72
66
/**
73
67
* @inheritdoc
74
68
*/
@@ -77,9 +71,6 @@ protected function setUp()
77
71
$ objectManager = Bootstrap::getObjectManager ();
78
72
$ this ->customerTokenService = $ objectManager ->get (CustomerTokenServiceInterface::class);
79
73
$ this ->getMaskedQuoteIdByReservedOrderId = $ objectManager ->get (GetMaskedQuoteIdByReservedOrderId::class);
80
- $ this ->getQuoteShippingAddressIdByReservedQuoteId = $ objectManager ->get (
81
- GetQuoteShippingAddressIdByReservedQuoteId::class
82
- );
83
74
}
84
75
85
76
/**
@@ -99,9 +90,8 @@ public function testSetUspsShippingMethod(string $methodCode, string $methodLabe
99
90
{
100
91
$ quoteReservedId = 'test_quote ' ;
101
92
$ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ($ quoteReservedId );
102
- $ shippingAddressId = $ this ->getQuoteShippingAddressIdByReservedQuoteId ->execute ($ quoteReservedId );
103
93
104
- $ query = $ this ->getQuery ($ maskedQuoteId , $ shippingAddressId , self ::CARRIER_CODE , $ methodCode );
94
+ $ query = $ this ->getQuery ($ maskedQuoteId , self ::CARRIER_CODE , $ methodCode );
105
95
$ response = $ this ->sendRequestWithToken ($ query );
106
96
107
97
self ::assertArrayHasKey ('setShippingMethodsOnCart ' , $ response );
@@ -118,10 +108,13 @@ public function testSetUspsShippingMethod(string $methodCode, string $methodLabe
118
108
self ::assertArrayHasKey ('method_code ' , $ shippingAddress ['selected_shipping_method ' ]);
119
109
self ::assertEquals ($ methodCode , $ shippingAddress ['selected_shipping_method ' ]['method_code ' ]);
120
110
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 ' ]);
122
115
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 ' ]
125
118
);
126
119
}
127
120
@@ -163,9 +156,8 @@ public function testSetUspsShippingMethodBasedOnCanadaAddress(string $methodCode
163
156
{
164
157
$ quoteReservedId = 'test_quote ' ;
165
158
$ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ($ quoteReservedId );
166
- $ shippingAddressId = $ this ->getQuoteShippingAddressIdByReservedQuoteId ->execute ($ quoteReservedId );
167
159
168
- $ query = $ this ->getQuery ($ maskedQuoteId , $ shippingAddressId , self ::CARRIER_CODE , $ methodCode );
160
+ $ query = $ this ->getQuery ($ maskedQuoteId , self ::CARRIER_CODE , $ methodCode );
169
161
$ response = $ this ->sendRequestWithToken ($ query );
170
162
171
163
self ::assertArrayHasKey ('setShippingMethodsOnCart ' , $ response );
@@ -182,10 +174,13 @@ public function testSetUspsShippingMethodBasedOnCanadaAddress(string $methodCode
182
174
self ::assertArrayHasKey ('method_code ' , $ shippingAddress ['selected_shipping_method ' ]);
183
175
self ::assertEquals ($ methodCode , $ shippingAddress ['selected_shipping_method ' ]['method_code ' ]);
184
176
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 ' ]);
186
181
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 ' ]
189
184
);
190
185
}
191
186
@@ -211,15 +206,13 @@ public function dataProviderShippingMethodsBasedOnCanadaAddress(): array
211
206
/**
212
207
* Generates query for setting the specified shipping method on cart
213
208
*
214
- * @param int $shippingAddressId
215
209
* @param string $maskedQuoteId
216
210
* @param string $carrierCode
217
211
* @param string $methodCode
218
212
* @return string
219
213
*/
220
214
private function getQuery (
221
215
string $ maskedQuoteId ,
222
- int $ shippingAddressId ,
223
216
string $ carrierCode ,
224
217
string $ methodCode
225
218
): string {
@@ -229,7 +222,6 @@ private function getQuery(
229
222
cart_id: " $ maskedQuoteId"
230
223
shipping_methods: [
231
224
{
232
- cart_address_id: $ shippingAddressId
233
225
carrier_code: " $ carrierCode"
234
226
method_code: " $ methodCode"
235
227
}
@@ -240,7 +232,8 @@ private function getQuery(
240
232
selected_shipping_method {
241
233
carrier_code
242
234
method_code
243
- label
235
+ carrier_title
236
+ method_title
244
237
}
245
238
}
246
239
}
0 commit comments