@@ -207,4 +207,60 @@ public function testSetAddressForVirtualQuote()
207
207
208
208
$ this ->_webApiCall ($ serviceInfo , $ requestData );
209
209
}
210
+
211
+ /**
212
+ * Test getting shipping address based on the customer's authentication token.
213
+ *
214
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
215
+ */
216
+ public function testGetMyAddress ()
217
+ {
218
+ // get customer ID token
219
+ /** @var \Magento\Integration\Service\V1\CustomerTokenServiceInterface $customerTokenService */
220
+ $ customerTokenService = $ this ->objectManager ->create (
221
+ 'Magento\Integration\Service\V1\CustomerTokenServiceInterface '
222
+ );
223
+ $ token = $ customerTokenService ->createCustomerAccessToken ('customer@example.com ' , 'password ' );
224
+
225
+ /** @var \Magento\Quote\Model\Quote $quote */
226
+ $ quote = $ this ->objectManager ->create ('Magento\Quote\Model\Quote ' );
227
+ $ quote ->load ('test_order_1 ' , 'reserved_order_id ' );
228
+
229
+ /** @var \Magento\Quote\Model\Quote\Address $address */
230
+ $ address = $ quote ->getShippingAddress ();
231
+
232
+ $ addressData = [
233
+ AddressInterface::KEY_COUNTRY_ID => $ address ->getCountryId (),
234
+ AddressInterface::KEY_ID => (int )$ address ->getId (),
235
+ AddressInterface::KEY_CUSTOMER_ID => $ address ->getCustomerId (),
236
+ AddressInterface::KEY_REGION => $ address ->getRegion (),
237
+ AddressInterface::KEY_REGION_ID => $ address ->getRegionId (),
238
+ AddressInterface::KEY_REGION_CODE => $ address ->getRegionCode (),
239
+ AddressInterface::KEY_STREET => $ address ->getStreet (),
240
+ AddressInterface::KEY_COMPANY => $ address ->getCompany (),
241
+ AddressInterface::KEY_TELEPHONE => $ address ->getTelephone (),
242
+ AddressInterface::KEY_POSTCODE => $ address ->getPostcode (),
243
+ AddressInterface::KEY_CITY => $ address ->getCity (),
244
+ AddressInterface::KEY_FIRSTNAME => $ address ->getFirstname (),
245
+ AddressInterface::KEY_LASTNAME => $ address ->getLastname (),
246
+ AddressInterface::KEY_EMAIL => $ address ->getEmail ()
247
+ ];
248
+
249
+ $ serviceInfo = [
250
+ 'rest ' => [
251
+ 'resourcePath ' => self ::RESOURCE_PATH . 'mine/shipping-address ' ,
252
+ 'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_GET ,
253
+ 'token ' => $ token
254
+ ],
255
+ 'soap ' => [
256
+ 'service ' => self ::SERVICE_NAME ,
257
+ 'serviceVersion ' => self ::SERVICE_VERSION ,
258
+ 'operation ' => self ::SERVICE_NAME . 'Get ' ,
259
+ 'token ' => $ token
260
+ ],
261
+ ];
262
+
263
+ $ requestData = ['cartId ' => $ quote ->getId ()];
264
+ $ this ->assertEquals ($ addressData , $ this ->_webApiCall ($ serviceInfo , $ requestData ));
265
+ }
210
266
}
0 commit comments