@@ -49,8 +49,8 @@ protected function setUp()
49
49
}
50
50
51
51
/**
52
- * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
53
52
* @magentoApiDataFixture Magento/Customer/_files/customer.php
53
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
54
54
*/
55
55
public function testSetNewShippingAddress ()
56
56
{
@@ -107,46 +107,6 @@ public function testSetNewShippingAddress()
107
107
$ this ->assertNewShippingAddressFields ($ shippingAddressResponse );
108
108
}
109
109
110
- /**
111
- * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
112
- * @magentoApiDataFixture Magento/Customer/_files/customer.php
113
- * @dataProvider requestWithoutRequiredParamsDataProvider
114
- * @param string $params
115
- * @param string $expectedException
116
- * @throws \Exception
117
- */
118
- public function testSetNewShippingAddressWithEmptyRequiredParams (string $ params , string $ expectedException )
119
- {
120
- $ maskedQuoteId = $ this ->assignQuoteToCustomer ();
121
-
122
- $ query = <<<QUERY
123
- mutation {
124
- setShippingAddressesOnCart(
125
- input: {
126
- cart_id: " $ maskedQuoteId"
127
- shipping_addresses: [
128
- {
129
- address: {
130
- $ params
131
- }
132
- }
133
- ]
134
- }
135
- ) {
136
- cart {
137
- shipping_addresses {
138
- city
139
- }
140
- }
141
- }
142
- }
143
- QUERY ;
144
- $ this ->expectExceptionMessage (
145
- $ expectedException
146
- );
147
- $ this ->graphQlQuery ($ query , [], '' , $ this ->getHeaderMap ());
148
- }
149
-
150
110
/**
151
111
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_saved.php
152
112
* @magentoApiDataFixture Magento/Customer/_files/customer.php
@@ -241,7 +201,7 @@ public function testSetShippingAddressFromAddressBook()
241
201
* @expectedException \Exception
242
202
* @expectedExceptionMessage Could not find a address with ID "100"
243
203
*/
244
- public function testSetNotExistedShippingAddressFromAddressBook ()
204
+ public function testSetNonExistentShippingAddressFromAddressBook ()
245
205
{
246
206
$ maskedQuoteId = $ this ->assignQuoteToCustomer ();
247
207
@@ -356,7 +316,7 @@ public function testSetShippingAddressIfCustomerIsNotOwnerOfAddress()
356
316
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
357
317
* @expectedException \Exception
358
318
*/
359
- public function testSetShippingAddressIfCustomerIsNotOwnerOfCart ()
319
+ public function testSetShippingAddressToAnotherCustomerCart ()
360
320
{
361
321
$ maskedQuoteId = $ this ->assignQuoteToCustomer ('test_order_with_simple_product_without_address ' , 1 );
362
322
@@ -388,19 +348,116 @@ public function testSetShippingAddressIfCustomerIsNotOwnerOfCart()
388
348
}
389
349
390
350
/**
391
- * TODO: currently only the city param is required, do we need to add at least ZIP code?
351
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
352
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
353
+ * @dataProvider dataProviderUpdateWithMissedRequiredParameters
354
+ * @param string $input
355
+ * @param string $message
356
+ * @throws \Exception
357
+ */
358
+ public function testSetNewShippingAddressWithMissedRequiredParameters (string $ input , string $ message )
359
+ {
360
+ $ maskedQuoteId = $ this ->assignQuoteToCustomer ();
361
+
362
+ $ query = <<<QUERY
363
+ mutation {
364
+ setShippingAddressesOnCart(
365
+ input: {
366
+ cart_id: " {$ maskedQuoteId }"
367
+ shipping_addresses: [
368
+ {
369
+ {$ input }
370
+ }
371
+ ]
372
+ }
373
+ ) {
374
+ cart {
375
+ shipping_addresses {
376
+ city
377
+ }
378
+ }
379
+ }
380
+ }
381
+ QUERY ;
382
+ $ this ->expectExceptionMessage ($ message );
383
+ $ this ->graphQlQuery ($ query , [], '' , $ this ->getHeaderMap ());
384
+ }
385
+
386
+ /**
392
387
* @return array
393
388
*/
394
- public function requestWithoutRequiredParamsDataProvider ()
389
+ public function dataProviderUpdateWithMissedRequiredParameters ()
395
390
{
396
391
return [
397
- [
398
- 'save_in_address_book: false ' ,
392
+ 'shipping_addresses ' => [
393
+ '' ,
394
+ 'The shipping address must contain either "customer_address_id" or "address". ' ,
395
+ ],
396
+ 'missed_city ' => [
397
+ 'address: { save_in_address_book: false } ' ,
399
398
'Field CartAddressInput.city of required type String! was not provided '
400
399
]
401
400
];
402
401
}
403
402
403
+ /**
404
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
405
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
406
+ * @expectedException \Exception
407
+ * @expectedExceptionMessage You cannot specify multiple shipping addresses.
408
+ */
409
+ public function testSetMultipleNewShippingAddresses ()
410
+ {
411
+ $ maskedQuoteId = $ this ->assignQuoteToCustomer ();
412
+
413
+ $ query = <<<QUERY
414
+ mutation {
415
+ setShippingAddressesOnCart(
416
+ input: {
417
+ cart_id: " $ maskedQuoteId"
418
+ shipping_addresses: [
419
+ {
420
+ address: {
421
+ firstname: "test firstname"
422
+ lastname: "test lastname"
423
+ company: "test company"
424
+ street: ["test street 1", "test street 2"]
425
+ city: "test city"
426
+ region: "test region"
427
+ postcode: "887766"
428
+ country_code: "US"
429
+ telephone: "88776655"
430
+ save_in_address_book: false
431
+ }
432
+ },
433
+ {
434
+ address: {
435
+ firstname: "test firstname 2"
436
+ lastname: "test lastname 2"
437
+ company: "test company 2"
438
+ street: ["test street 1", "test street 2"]
439
+ city: "test city"
440
+ region: "test region"
441
+ postcode: "887766"
442
+ country_code: "US"
443
+ telephone: "88776655"
444
+ save_in_address_book: false
445
+ }
446
+ }
447
+ ]
448
+ }
449
+ ) {
450
+ cart {
451
+ shipping_addresses {
452
+ city
453
+ }
454
+ }
455
+ }
456
+ }
457
+ QUERY ;
458
+ $ this ->graphQlQuery ($ query , [], '' , $ this ->getHeaderMap ());
459
+ }
460
+
404
461
/**
405
462
* Verify the all the whitelisted fields for a New Address Object
406
463
*
0 commit comments