Skip to content

Commit e9b6334

Browse files
author
Vitaliy Boyko
committed
graphQl-784: added guest tests
1 parent 28c5a88 commit e9b6334

File tree

5 files changed

+49
-63
lines changed

5 files changed

+49
-63
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct(
6161
public function createBasedOnInputData(array $addressInput): QuoteAddress
6262
{
6363
$addressInput['country_id'] = $addressInput['country_code'] ?? '';
64-
if ($addressInput['country_id'] && !ctype_upper($addressInput['country_code'] )) {
64+
if ($addressInput['country_id'] && !ctype_upper($addressInput['country_code'])) {
6565
throw new GraphQlInputException(
6666
__('"Country Code" cannot contain lowercase characters.')
6767
);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ public function testSetNewBillingAddressWithRedundantStreetLine()
645645
* @expectedException \Exception
646646
* @expectedExceptionMessage "Country Code" cannot contain lowercase characters.
647647
*/
648-
public function testSetNewBillingAddressWithLowercaseCountryCode()
648+
public function testSetBillingAddressWithLowerCaseCountry()
649649
{
650650
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
651651

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

+1-54
Original file line numberDiff line numberDiff line change
@@ -602,59 +602,6 @@ public function testSetShippingAddressToGuestCart()
602602
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
603603
}
604604

605-
/**
606-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
607-
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
608-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
609-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
610-
*/
611-
public function testSetShippingAddressWithLowerCaseCountry()
612-
{
613-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
614-
615-
$query = <<<QUERY
616-
mutation {
617-
setShippingAddressesOnCart(
618-
input: {
619-
cart_id: "{$maskedQuoteId}"
620-
shipping_addresses: [
621-
{
622-
address: {
623-
firstname: "John"
624-
lastname: "Doe"
625-
street: ["6161 West Centinella Avenue"]
626-
city: "Culver City"
627-
region: "CA"
628-
postcode: "90230"
629-
country_code: "us"
630-
telephone: "555-555-55-55"
631-
}
632-
}
633-
]
634-
}
635-
) {
636-
cart {
637-
shipping_addresses {
638-
region {
639-
code
640-
}
641-
country {
642-
code
643-
}
644-
}
645-
}
646-
}
647-
}
648-
QUERY;
649-
$result = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
650-
651-
self::assertCount(1, $result['setShippingAddressesOnCart']['cart']['shipping_addresses']);
652-
$address = reset($result['setShippingAddressesOnCart']['cart']['shipping_addresses']);
653-
654-
$this->assertEquals('US', $address['country']['code']);
655-
$this->assertEquals('CA', $address['region']['code']);
656-
}
657-
658605
/**
659606
* @magentoApiDataFixture Magento/Customer/_files/customer.php
660607
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
@@ -663,7 +610,7 @@ public function testSetShippingAddressWithLowerCaseCountry()
663610
* @expectedException \Exception
664611
* @expectedExceptionMessage "Country Code" cannot contain lowercase characters.
665612
*/
666-
public function testSetNewShippingAddressOnCartWithLowercaseCountryCode()
613+
public function testSetShippingAddressWithLowerCaseCountry()
667614
{
668615
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
669616

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

+43
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,49 @@ public function testSetNewBillingAddressRedundantStreetLine()
455455
$this->graphQlMutation($query);
456456
}
457457

458+
/**
459+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
460+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
461+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
462+
* @expectedException \Exception
463+
* @expectedExceptionMessage "Country Code" cannot contain lowercase characters.
464+
*/
465+
public function testSetBillingAddressWithLowerCaseCountry()
466+
{
467+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
468+
469+
$query = <<<QUERY
470+
mutation {
471+
setBillingAddressOnCart(
472+
input: {
473+
cart_id: "$maskedQuoteId"
474+
billing_address: {
475+
address: {
476+
firstname: "test firstname"
477+
lastname: "test lastname"
478+
company: "test company"
479+
street: ["test street 1", "test street 2"]
480+
city: "test city"
481+
region: "test region"
482+
postcode: "887766"
483+
country_code: "us"
484+
telephone: "88776655"
485+
save_in_address_book: false
486+
}
487+
}
488+
}
489+
) {
490+
cart {
491+
billing_address {
492+
firstname
493+
}
494+
}
495+
}
496+
}
497+
QUERY;
498+
$this->graphQlMutation($query);
499+
}
500+
458501
/**
459502
* Verify the all the whitelisted fields for a New Address Object
460503
*

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

+3-7
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ public function testSetShippingAddressOnNonExistentCart()
411411
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
412412
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
413413
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
414+
* @expectedException \Exception
415+
* @expectedExceptionMessage "Country Code" cannot contain lowercase characters.
414416
*/
415417
public function testSetShippingAddressWithLowerCaseCountry()
416418
{
@@ -450,13 +452,7 @@ public function testSetShippingAddressWithLowerCaseCountry()
450452
}
451453
}
452454
QUERY;
453-
$result = $this->graphQlMutation($query);
454-
455-
self::assertCount(1, $result['setShippingAddressesOnCart']['cart']['shipping_addresses']);
456-
$address = reset($result['setShippingAddressesOnCart']['cart']['shipping_addresses']);
457-
458-
$this->assertEquals('US', $address['country']['code']);
459-
$this->assertEquals('CA', $address['region']['code']);
455+
$this->graphQlMutation($query);
460456
}
461457

462458
/**

0 commit comments

Comments
 (0)