Skip to content

Commit 9630af6

Browse files
authored
LYNX-187: prefix, suffix, middlename and fax fields missing in setShippingAddressesOnCart and setBillingAddressOnCart graphQL mutations
1 parent 7a00ab7 commit 9630af6

File tree

3 files changed

+216
-0
lines changed

3 files changed

+216
-0
lines changed

app/code/Magento/QuoteGraphQl/etc/schema.graphqls

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ input CartAddressInput @doc(description: "Defines the billing or shipping addres
126126
telephone: String @doc(description: "The telephone number for the billing or shipping address.")
127127
vat_id: String @doc(description: "The VAT company number for billing or shipping address.")
128128
save_in_address_book: Boolean @doc(description: "Determines whether to save the address in the customer's address book. The default value is true.")
129+
fax: String @doc(description: "The customer's fax number.")
130+
middlename: String @doc(description: "The middle name of the person associated with the billing/shipping address.")
131+
prefix: String @doc(description: "An honorific, such as Dr., Mr., or Mrs.")
132+
suffix: String @doc(description: "A value such as Sr., Jr., or III.")
129133
}
130134

131135
input SetShippingMethodsOnCartInput @doc(description: "Applies one or shipping methods to the cart.") {
@@ -233,6 +237,10 @@ interface CartAddressInterface @typeResolver(class: "\\Magento\\QuoteGraphQl\\Mo
233237
country: CartAddressCountry! @doc(description: "An object containing the country label and code.")
234238
telephone: String @doc(description: "The telephone number for the billing or shipping address.")
235239
vat_id: String @doc(description: "The VAT company number for billing or shipping address.")
240+
fax: String @doc(description: "The customer's fax number.")
241+
middlename: String @doc(description: "The middle name of the person associated with the billing/shipping address.")
242+
prefix: String @doc(description: "An honorific, such as Dr., Mr., or Mrs.")
243+
suffix: String @doc(description: "A value such as Sr., Jr., or III.")
236244
}
237245

238246
type ShippingCartAddress implements CartAddressInterface @doc(description: "Contains shipping addresses and methods.") {

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

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77

88
namespace Magento\GraphQl\Quote\Guest;
99

10+
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
12+
use Magento\Quote\Model\ResourceModel\Quote\QuoteIdMask;
13+
use Magento\Quote\Test\Fixture\GuestCart;
14+
use Magento\Quote\Test\Fixture\QuoteIdMask as QuoteIdMaskFixture;
15+
use Magento\TestFramework\Fixture\DataFixture;
16+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1117
use Magento\TestFramework\Helper\Bootstrap;
1218
use Magento\TestFramework\TestCase\GraphQlAbstract;
1319

@@ -583,6 +589,99 @@ public function testSetBillingAddressWithSameAsShippingAndMultishipping()
583589
$this->graphQlMutation($query);
584590
}
585591

592+
/**
593+
* Test graphql mutation setting middlename, prefix, suffix and fax in billing address
594+
*
595+
* @throws LocalizedException
596+
*/
597+
#[
598+
DataFixture(GuestCart::class, as: 'quote'),
599+
DataFixture(QuoteIdMaskFixture::class, ['cart_id' => '$quote.id$'], as: 'mask'),
600+
]
601+
public function testSetMiddlenamePrefixSuffixFaxBillingAddress()
602+
{
603+
/** @var QuoteIdMask $quoteMask */
604+
$quoteMask = Bootstrap::getObjectManager()->get(DataFixtureStorageManager::class)->getStorage()->get('mask');
605+
606+
$expectedResult = [
607+
'setBillingAddressOnCart' => [
608+
'cart' => [
609+
'billing_address' => [
610+
'firstname' => 'test firstname',
611+
'lastname' => 'test lastname',
612+
'middlename' => 'test middlename',
613+
'prefix' => 'Mr.',
614+
'suffix' => 'Jr.',
615+
'fax' => '5552224455',
616+
'company' => 'test company',
617+
'street' => [
618+
'test street 1',
619+
'test street 2',
620+
],
621+
'city' => 'test city',
622+
'postcode' => '887766',
623+
'telephone' => '88776655',
624+
'country' => [
625+
'code' => 'US',
626+
'label' => 'US',
627+
],
628+
'__typename' => 'BillingCartAddress'
629+
]
630+
]
631+
]
632+
];
633+
634+
$query = <<<QUERY
635+
mutation {
636+
setBillingAddressOnCart(
637+
input: {
638+
cart_id: "{$quoteMask->getMaskedId()}"
639+
billing_address: {
640+
address: {
641+
firstname: "test firstname"
642+
lastname: "test lastname"
643+
middlename: "test middlename"
644+
prefix: "Mr."
645+
suffix: "Jr."
646+
fax: "5552224455"
647+
company: "test company"
648+
street: ["test street 1", "test street 2"]
649+
city: "test city"
650+
region: "AL"
651+
postcode: "887766"
652+
country_code: "US"
653+
telephone: "88776655"
654+
}
655+
}
656+
}
657+
) {
658+
cart {
659+
billing_address {
660+
firstname
661+
lastname
662+
middlename
663+
prefix
664+
suffix
665+
fax
666+
company
667+
street
668+
city
669+
postcode
670+
telephone
671+
country {
672+
code
673+
label
674+
}
675+
__typename
676+
}
677+
}
678+
}
679+
}
680+
QUERY;
681+
$response = $this->graphQlMutation($query);
682+
$this->assertEquals($expectedResult, $response);
683+
}
684+
586685
/**
587686
* Verify all the whitelisted fields for a New Address Object
588687
*

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

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77

88
namespace Magento\GraphQl\Quote\Guest;
99

10+
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
12+
use Magento\Quote\Model\ResourceModel\Quote\QuoteIdMask;
13+
use Magento\Quote\Test\Fixture\GuestCart;
14+
use Magento\Quote\Test\Fixture\QuoteIdMask as QuoteIdMaskFixture;
15+
use Magento\TestFramework\Fixture\DataFixture;
16+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1117
use Magento\TestFramework\Helper\Bootstrap;
1218
use Magento\TestFramework\TestCase\GraphQlAbstract;
1319

@@ -371,6 +377,10 @@ public function testSetShippingAddressWithLowerCaseCountry()
371377
address: {
372378
firstname: "John"
373379
lastname: "Doe"
380+
middlename: "test middlename"
381+
prefix: "Mr."
382+
suffix: "Jr."
383+
fax: "5552224455"
374384
street: ["6161 West Centinella Avenue"]
375385
city: "Culver City"
376386
region: "CA"
@@ -423,6 +433,10 @@ public function testSetShippingAddressWithLowerCaseRegion()
423433
address: {
424434
firstname: "John"
425435
lastname: "Doe"
436+
middlename: "test middlename"
437+
prefix: "Mr."
438+
suffix: "Jr."
439+
fax: "5552224455"
426440
street: ["6161 West Centinella Avenue"]
427441
city: "Culver City"
428442
region: "ca"
@@ -456,6 +470,101 @@ public function testSetShippingAddressWithLowerCaseRegion()
456470
$this->assertEquals('CA', $address['region']['code']);
457471
}
458472

473+
/**
474+
* Test graphql mutation setting middlename, prefix, suffix and fax in shipping address
475+
*
476+
* @throws LocalizedException
477+
*/
478+
#[
479+
DataFixture(GuestCart::class, as: 'quote'),
480+
DataFixture(QuoteIdMaskFixture::class, ['cart_id' => '$quote.id$'], as: 'mask'),
481+
]
482+
public function testSetMiddlenamePrefixSuffixFaxShippingAddress()
483+
{
484+
/** @var QuoteIdMask $quoteMask */
485+
$quoteMask = Bootstrap::getObjectManager()->get(DataFixtureStorageManager::class)->getStorage()->get('mask');
486+
487+
$expectedResult = [
488+
'setShippingAddressesOnCart' => [
489+
'cart' => [
490+
'shipping_addresses' => [
491+
[
492+
'firstname' => 'test firstname',
493+
'lastname' => 'test lastname',
494+
'middlename' => 'test middlename',
495+
'prefix' => 'Mr.',
496+
'suffix' => 'Jr.',
497+
'fax' => '5552224455',
498+
'company' => 'test company',
499+
'street' => [
500+
'test street 1',
501+
'test street 2',
502+
],
503+
'city' => 'test city',
504+
'postcode' => '887766',
505+
'telephone' => '88776655',
506+
'country' => [
507+
'code' => 'US',
508+
'label' => 'US',
509+
],
510+
'__typename' => 'ShippingCartAddress'
511+
]
512+
]
513+
]
514+
]
515+
];
516+
517+
$query = <<<QUERY
518+
mutation {
519+
setShippingAddressesOnCart(
520+
input: {
521+
cart_id: "{$quoteMask->getMaskedId()}"
522+
shipping_addresses: {
523+
address: {
524+
firstname: "test firstname"
525+
lastname: "test lastname"
526+
middlename: "test middlename"
527+
prefix: "Mr."
528+
suffix: "Jr."
529+
fax: "5552224455"
530+
company: "test company"
531+
street: ["test street 1", "test street 2"]
532+
city: "test city"
533+
region: "AL"
534+
postcode: "887766"
535+
country_code: "US"
536+
telephone: "88776655"
537+
}
538+
}
539+
}
540+
) {
541+
cart {
542+
shipping_addresses {
543+
firstname
544+
lastname
545+
middlename
546+
prefix
547+
suffix
548+
fax
549+
company
550+
street
551+
city
552+
postcode
553+
telephone
554+
country {
555+
code
556+
label
557+
}
558+
__typename
559+
}
560+
}
561+
}
562+
}
563+
QUERY;
564+
$response = $this->graphQlMutation($query);
565+
$this->assertEquals($expectedResult, $response);
566+
}
567+
459568
/**
460569
* Verify the all the whitelisted fields for a New Address Object
461570
*

0 commit comments

Comments
 (0)