@@ -96,7 +96,7 @@ public function testSetNewBillingAddress()
96
96
company: "test company"
97
97
street: ["test street 1", "test street 2"]
98
98
city: "test city"
99
- region: "test region "
99
+ region: "AZ "
100
100
postcode: "887766"
101
101
country_code: "US"
102
102
telephone: "88776655"
@@ -174,7 +174,7 @@ public function testSetNewBillingAddressWithUseForShippingParameter()
174
174
company: "test company"
175
175
street: ["test street 1", "test street 2"]
176
176
city: "test city"
177
- region: "test region "
177
+ region: "AZ "
178
178
postcode: "887766"
179
179
country_code: "US"
180
180
telephone: "88776655"
@@ -370,7 +370,7 @@ public function testSetNewBillingAddressAndFromAddressBookAtSameTime()
370
370
company: "test company"
371
371
street: ["test street 1", "test street 2"]
372
372
city: "test city"
373
- region: "test region "
373
+ region: "AZ "
374
374
postcode: "887766"
375
375
country_code: "US"
376
376
telephone: "88776655"
@@ -451,7 +451,7 @@ public function testSetNewBillingAddressWithSameAsShippingAndMultishipping()
451
451
company: "test company"
452
452
street: ["test street 1", "test street 2"]
453
453
city: "test city"
454
- region: "test region "
454
+ region: "AZ "
455
455
postcode: "887766"
456
456
country_code: "US"
457
457
telephone: "88776655"
@@ -644,7 +644,7 @@ public function testSetBillingAddressWithoutRequiredParameters(string $input, st
644
644
QUERY ;
645
645
646
646
$ this ->expectExceptionMessage ($ message );
647
- $ this ->graphQlMutation ($ query );
647
+ $ this ->graphQlMutation ($ query, [], '' , $ this -> getHeaderMap () );
648
648
}
649
649
650
650
/**
@@ -661,7 +661,55 @@ public function dataProviderSetWithoutRequiredParameters(): array
661
661
'missed_cart_id ' => [
662
662
'billing_address: {} ' ,
663
663
'Required parameter "cart_id" is missing '
664
- ]
664
+ ],
665
+ 'missed_region ' => [
666
+ 'cart_id: "cart_id_value"
667
+ billing_address: {
668
+ address: {
669
+ firstname: "test firstname"
670
+ lastname: "test lastname"
671
+ company: "test company"
672
+ street: ["test street 1", "test street 2"]
673
+ city: "test city"
674
+ postcode: "887766"
675
+ country_code: "US"
676
+ telephone: "88776655"
677
+ }
678
+ } ' ,
679
+ '"regionId" is required. Enter and try again. '
680
+ ],
681
+ 'missed_multiple_fields ' => [
682
+ 'cart_id: "cart_id_value"
683
+ billing_address: {
684
+ address: {
685
+ firstname: "test firstname"
686
+ lastname: "test lastname"
687
+ company: "test company"
688
+ street: ["test street 1", "test street 2"]
689
+ city: "test city"
690
+ country_code: "US"
691
+ telephone: "88776655"
692
+ }
693
+ } ' ,
694
+ '"postcode" is required. Enter and try again.
695
+ "regionId" is required. Enter and try again. '
696
+ ],
697
+ 'wrong_required_region ' => [
698
+ 'cart_id: "cart_id_value"
699
+ billing_address: {
700
+ address: {
701
+ firstname: "test firstname"
702
+ lastname: "test lastname"
703
+ company: "test company"
704
+ street: ["test street 1", "test street 2"]
705
+ region: "wrong region"
706
+ city: "test city"
707
+ country_code: "US"
708
+ telephone: "88776655"
709
+ }
710
+ } ' ,
711
+ 'Region is not available for the selected country '
712
+ ],
665
713
];
666
714
}
667
715
@@ -687,7 +735,7 @@ public function testSetNewBillingAddressWithRedundantStreetLine()
687
735
company: "test company"
688
736
street: ["test street 1", "test street 2", "test street 3"]
689
737
city: "test city"
690
- region: "test region "
738
+ region: "AZ "
691
739
postcode: "887766"
692
740
country_code: "US"
693
741
telephone: "88776655"
@@ -729,7 +777,7 @@ public function testSetBillingAddressWithLowerCaseCountry()
729
777
company: "test company"
730
778
street: ["test street 1", "test street 2"]
731
779
city: "test city"
732
- region: "test region "
780
+ region: "AZ "
733
781
postcode: "887766"
734
782
country_code: "us"
735
783
telephone: "88776655"
@@ -786,7 +834,7 @@ public function testSetNewBillingAddressWithSaveInAddressBook()
786
834
company: "test company"
787
835
street: ["test street 1", "test street 2"]
788
836
city: "test city"
789
- region: "test region "
837
+ region: "AZ "
790
838
postcode: "887766"
791
839
country_code: "US"
792
840
telephone: "88776655"
@@ -853,7 +901,7 @@ public function testSetNewBillingAddressWithNotSaveInAddressBook()
853
901
company: "test company"
854
902
street: ["test street 1", "test street 2"]
855
903
city: "test city"
856
- region: "test region "
904
+ region: "AZ "
857
905
postcode: "887766"
858
906
country_code: "US"
859
907
telephone: "88776655"
@@ -921,7 +969,7 @@ public function testWithInvalidBillingAddressInput()
921
969
company: "test company"
922
970
street: ["test street 1", "test street 2"]
923
971
city: "test city"
924
- region: "test region "
972
+ region: "AZ "
925
973
postcode: "887766"
926
974
country_code: "USS"
927
975
telephone: "88776655"
@@ -948,10 +996,59 @@ public function testWithInvalidBillingAddressInput()
948
996
}
949
997
}
950
998
QUERY ;
951
- $ this ->expectExceptionMessage ('The address failed to save. Verify the address and try again. ' );
999
+ $ this ->expectExceptionMessage ('Country is not available ' );
952
1000
$ this ->graphQlMutation ($ query , [], '' , $ this ->getHeaderMap ());
953
1001
}
954
1002
1003
+ /**
1004
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
1005
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
1006
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
1007
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
1008
+ */
1009
+ public function testSetShippingAddressesWithNotRequiredRegion ()
1010
+ {
1011
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
1012
+
1013
+ $ query = <<<QUERY
1014
+ mutation {
1015
+ setBillingAddressOnCart(
1016
+ input: {
1017
+ cart_id: " $ maskedQuoteId"
1018
+ billing_address: {
1019
+ address: {
1020
+ firstname: "Vasyl"
1021
+ lastname: "Doe"
1022
+ street: ["1 Svobody"]
1023
+ city: "Lviv"
1024
+ region: "Lviv"
1025
+ postcode: "00000"
1026
+ country_code: "UA"
1027
+ telephone: "555-555-55-55"
1028
+ }
1029
+ }
1030
+ }
1031
+ ) {
1032
+ cart {
1033
+ billing_address {
1034
+ region {
1035
+ label
1036
+ }
1037
+ country {
1038
+ code
1039
+ }
1040
+ }
1041
+ }
1042
+ }
1043
+ }
1044
+ QUERY ;
1045
+ $ response = $ this ->graphQlMutation ($ query , [], '' , $ this ->getHeaderMap ());
1046
+ self ::assertArrayHasKey ('cart ' , $ response ['setBillingAddressOnCart ' ]);
1047
+ $ cartResponse = $ response ['setBillingAddressOnCart ' ]['cart ' ];
1048
+ self ::assertEquals ('UA ' , $ cartResponse ['billing_address ' ]['country ' ]['code ' ]);
1049
+ self ::assertEquals ('Lviv ' , $ cartResponse ['billing_address ' ]['region ' ]['label ' ]);
1050
+ }
1051
+
955
1052
/**
956
1053
* Verify the all the whitelisted fields for a New Address Object
957
1054
*
0 commit comments