@@ -164,28 +164,25 @@ private function assertCustomerAddressesFields(AddressInterface $address, $actua
164
164
}
165
165
166
166
/**
167
- * Update address with invalid ID
167
+ * Update address with missing ID input.
168
168
*
169
169
* @magentoApiDataFixture Magento/Customer/_files/customer.php
170
170
* @magentoApiDataFixture Magento/Customer/_files/customer_address.php
171
171
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
172
- * @dataProvider invalidIdDataProvider
173
- * @param string $addressId
174
- * @param $exceptionMessage
175
172
*/
176
- public function testCreateCustomerAddressWithInvalidId ( $ addressId , $ exceptionMessage )
173
+ public function testUpdateCustomerAddressWithMissingId ( )
177
174
{
178
175
$ userName = 'customer@example.com ' ;
179
176
$ password = 'password ' ;
180
177
181
178
$ updateAddress = $ this ->getAddressData ();
182
- $ defaultShippingText = $ updateAddress ['default_shipping ' ] ? " true " : " false " ;
183
- $ defaultBillingText = $ updateAddress ['default_billing ' ] ? " true " : " false " ;
179
+ $ defaultShippingText = $ updateAddress ['default_shipping ' ] ? ' true ' : ' false ' ;
180
+ $ defaultBillingText = $ updateAddress ['default_billing ' ] ? ' true ' : ' false ' ;
184
181
185
182
$ mutation
186
183
= <<<MUTATION
187
184
mutation {
188
- updateCustomerAddress( $ addressId , input: {
185
+ updateCustomerAddress(, input: {
189
186
region: {
190
187
region: " {$ updateAddress ['region ' ]['region ' ]}"
191
188
region_id: {$ updateAddress ['region ' ]['region_id ' ]}
@@ -212,17 +209,76 @@ public function testCreateCustomerAddressWithInvalidId($addressId, $exceptionMes
212
209
}
213
210
MUTATION ;
214
211
215
- self ::expectException (Exception::class);
216
- self ::expectExceptionMessage ($ exceptionMessage );
217
- $ this ->graphQlMutation ($ mutation , [], '' , $ this ->getCustomerAuthHeaders ($ userName , $ password )); }
212
+ $ this ->expectException (Exception::class);
213
+ $ this ->expectExceptionMessage (
214
+ 'GraphQL response contains errors: Field "updateCustomerAddress" argument "id" of type "Int!" is ' .
215
+ 'required but not provided. '
216
+ );
217
+ $ this ->graphQlMutation ($ mutation , [], '' , $ this ->getCustomerAuthHeaders ($ userName , $ password ));
218
+ }
219
+
220
+ /**
221
+ * Update address with invalid ID input.
222
+ *
223
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
224
+ * @magentoApiDataFixture Magento/Customer/_files/customer_address.php
225
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
226
+ */
227
+ public function testUpdateCustomerAddressWithInvalidIdType ()
228
+ {
229
+ $ this ->markTestSkipped (
230
+ 'Type validation returns wrong message https://github.com/magento/graphql-ce/issues/735 '
231
+ );
232
+ $ userName = 'customer@example.com ' ;
233
+ $ password = 'password ' ;
234
+
235
+ $ updateAddress = $ this ->getAddressData ();
236
+ $ defaultShippingText = $ updateAddress ['default_shipping ' ] ? 'true ' : 'false ' ;
237
+ $ defaultBillingText = $ updateAddress ['default_billing ' ] ? 'true ' : 'false ' ;
238
+
239
+ $ mutation
240
+ = <<<MUTATION
241
+ mutation {
242
+ updateCustomerAddress(id: "", input: {
243
+ region: {
244
+ region: " {$ updateAddress ['region ' ]['region ' ]}"
245
+ region_id: {$ updateAddress ['region ' ]['region_id ' ]}
246
+ region_code: " {$ updateAddress ['region ' ]['region_code ' ]}"
247
+ }
248
+ country_id: {$ updateAddress ['country_id ' ]}
249
+ street: [" {$ updateAddress ['street ' ][0 ]}"," {$ updateAddress ['street ' ][1 ]}"]
250
+ company: " {$ updateAddress ['company ' ]}"
251
+ telephone: " {$ updateAddress ['telephone ' ]}"
252
+ fax: " {$ updateAddress ['fax ' ]}"
253
+ postcode: " {$ updateAddress ['postcode ' ]}"
254
+ city: " {$ updateAddress ['city ' ]}"
255
+ firstname: " {$ updateAddress ['firstname ' ]}"
256
+ lastname: " {$ updateAddress ['lastname ' ]}"
257
+ middlename: " {$ updateAddress ['middlename ' ]}"
258
+ prefix: " {$ updateAddress ['prefix ' ]}"
259
+ suffix: " {$ updateAddress ['suffix ' ]}"
260
+ vat_id: " {$ updateAddress ['vat_id ' ]}"
261
+ default_shipping: {$ defaultShippingText }
262
+ default_billing: {$ defaultBillingText }
263
+ }) {
264
+ id
265
+ }
266
+ }
267
+ MUTATION ;
268
+
269
+ $ this ->expectException (Exception::class);
270
+ $ this ->expectExceptionMessage ('Expected type Int!, found "" ' );
271
+ $ this ->graphQlMutation ($ mutation , [], '' , $ this ->getCustomerAuthHeaders ($ userName , $ password ));
272
+ }
218
273
219
274
/**
220
275
* @return array
221
276
*/
222
277
public function invalidIdDataProvider ()
223
278
{
224
279
return [
225
- ['' , 'GraphQL response contains errors: Field "updateCustomerAddress" argument "id" of type "Int!" is required but not provided. ' ],
280
+ ['' , 'GraphQL response contains errors: Field "updateCustomerAddress" argument "id" of type "Int!" ' .
281
+ 'is required but not provided. ' ],
226
282
//TODO: why here the internal server error being trowed?
227
283
['id: "" ' , 'GraphQL response contains errors: Internal server error ' ]
228
284
];
@@ -235,9 +291,9 @@ public function invalidIdDataProvider()
235
291
* @magentoApiDataFixture Magento/Customer/_files/customer_address.php
236
292
* @dataProvider invalidInputDataProvider
237
293
* @param string $input
238
- * @param $exceptionMessage
294
+ * @param string $exceptionMessage
239
295
*/
240
- public function testUpdateCustomerAddressWithInvalidInput ($ input , $ exceptionMessage )
296
+ public function testUpdateCustomerAddressWithInvalidInput (string $ input , string $ exceptionMessage )
241
297
{
242
298
$ userName = 'customer@example.com ' ;
243
299
$ password = 'password ' ;
@@ -252,9 +308,10 @@ public function testUpdateCustomerAddressWithInvalidInput($input, $exceptionMess
252
308
}
253
309
MUTATION ;
254
310
255
- self ::expectException (Exception::class);
256
- self ::expectExceptionMessage ($ exceptionMessage );
257
- $ this ->graphQlMutation ($ mutation , [], '' , $ this ->getCustomerAuthHeaders ($ userName , $ password )); }
311
+ $ this ->expectException (Exception::class);
312
+ $ this ->expectExceptionMessage ($ exceptionMessage );
313
+ $ this ->graphQlMutation ($ mutation , [], '' , $ this ->getCustomerAuthHeaders ($ userName , $ password ));
314
+ }
258
315
259
316
/**
260
317
* @return array
@@ -282,14 +339,14 @@ public function testUpdateNotExistingCustomerAddress()
282
339
283
340
$ mutation = $ this ->getMutation ($ addressId );
284
341
285
- $ this ->graphQlMutation ($ mutation , [], '' , $ this ->getCustomerAuthHeaders ($ userName , $ password ));
342
+ $ this ->graphQlMutation ($ mutation , [], '' , $ this ->getCustomerAuthHeaders ($ userName , $ password ));
286
343
}
287
344
288
345
/**
289
346
* @magentoApiDataFixture Magento/Customer/_files/two_customers.php
290
347
* @magentoApiDataFixture Magento/Customer/_files/customer_address.php
291
348
* @expectedException Exception
292
- * @expectedExceptionMessage GraphQL response contains errors: Current customer does not have permission to address with ID "1"
349
+ * @expectedExceptionMessage Current customer does not have permission to address with ID "1"
293
350
*/
294
351
public function testUpdateAnotherCustomerAddress ()
295
352
{
@@ -307,7 +364,7 @@ public function testUpdateAnotherCustomerAddress()
307
364
* @magentoApiDataFixture Magento/Customer/_files/customer_address.php
308
365
* @magentoApiDataFixture Magento/Customer/_files/customer_confirmation_config_enable.php
309
366
* @expectedException Exception
310
- * @expectedExceptionMessage The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later.
367
+ * @expectedExceptionMessage The account sign-in was incorrect or your account is disabled temporarily.
311
368
*/
312
369
public function testUpdateCustomerAddressIfAccountIsNotConfirmed ()
313
370
{
@@ -324,7 +381,7 @@ public function testUpdateCustomerAddressIfAccountIsNotConfirmed()
324
381
* @magentoApiDataFixture Magento/Customer/_files/customer.php
325
382
* @magentoApiDataFixture Magento/Customer/_files/customer_address.php
326
383
* @expectedException Exception
327
- * @expectedExceptionMessage GraphQL response contains errors: The account is locked.
384
+ * @expectedExceptionMessage The account is locked.
328
385
*/
329
386
public function testUpdateCustomerAddressIfAccountIsLocked ()
330
387
{
0 commit comments