Skip to content

Commit

Permalink
magento/graphql-ce#903: [Checkout] Replace use_for_shipping with same…
Browse files Browse the repository at this point in the history
…_as_shipping
  • Loading branch information
lenaorobei committed Oct 23, 2019
1 parent 4939719 commit bb25f9a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
{
$customerAddressId = $billingAddressInput['customer_address_id'] ?? null;
$addressInput = $billingAddressInput['address'] ?? null;
$sameAsShipping = isset($billingAddressInput['same_as_shipping'])
? (bool)$billingAddressInput['same_as_shipping'] : false;
// Need to keep this for BC of `use_for_shipping` field
$sameAsShipping = isset($billingAddressInput['use_for_shipping'])
? (bool)$billingAddressInput['use_for_shipping'] : $sameAsShipping;
? (bool)$billingAddressInput['use_for_shipping'] : false;
$sameAsShipping = isset($billingAddressInput['same_as_shipping'])
? (bool)$billingAddressInput['same_as_shipping'] : $sameAsShipping;

if (null === $customerAddressId && null === $addressInput) {
throw new GraphQlInputException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,64 +86,6 @@ public function testSetNewBillingAddress()

$query = <<<QUERY
mutation {
setBillingAddressOnCart(
input: {
cart_id: "$maskedQuoteId"
billing_address: {
address: {
firstname: "test firstname"
lastname: "test lastname"
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
region: "test region"
postcode: "887766"
country_code: "US"
telephone: "88776655"
}
}
}
) {
cart {
billing_address {
firstname
lastname
company
street
city
postcode
telephone
country {
code
label
}
__typename
}
}
}
}
QUERY;
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());

self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']);
$cartResponse = $response['setBillingAddressOnCart']['cart'];
self::assertArrayHasKey('billing_address', $cartResponse);
$billingAddressResponse = $cartResponse['billing_address'];
$this->assertNewAddressFields($billingAddressResponse);
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
*/
public function testSetNewBillingAddressWithSameAsShippingParameter()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');

$query = <<<QUERY
mutation {
setBillingAddressOnCart(
input: {
cart_id: "$maskedQuoteId"
Expand Down Expand Up @@ -209,6 +151,8 @@ public function testSetNewBillingAddressWithSameAsShippingParameter()
}

/**
* Test case for deprecated `use_for_shipping` param.
*
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,63 +38,6 @@ public function testSetNewBillingAddress()

$query = <<<QUERY
mutation {
setBillingAddressOnCart(
input: {
cart_id: "$maskedQuoteId"
billing_address: {
address: {
firstname: "test firstname"
lastname: "test lastname"
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
region: "test region"
postcode: "887766"
country_code: "US"
telephone: "88776655"
}
}
}
) {
cart {
billing_address {
firstname
lastname
company
street
city
postcode
telephone
country {
code
label
}
__typename
}
}
}
}
QUERY;
$response = $this->graphQlMutation($query);

self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']);
$cartResponse = $response['setBillingAddressOnCart']['cart'];
self::assertArrayHasKey('billing_address', $cartResponse);
$billingAddressResponse = $cartResponse['billing_address'];
$this->assertNewAddressFields($billingAddressResponse);
}

/**
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
*/
public function testSetNewBillingAddressWithSameAsShippingParameter()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');

$query = <<<QUERY
mutation {
setBillingAddressOnCart(
input: {
cart_id: "$maskedQuoteId"
Expand Down Expand Up @@ -153,13 +96,16 @@ public function testSetNewBillingAddressWithSameAsShippingParameter()
$cartResponse = $response['setBillingAddressOnCart']['cart'];
self::assertArrayHasKey('billing_address', $cartResponse);
$billingAddressResponse = $cartResponse['billing_address'];
$this->assertNewAddressFields($billingAddressResponse);
self::assertArrayHasKey('shipping_addresses', $cartResponse);
$shippingAddressResponse = current($cartResponse['shipping_addresses']);
$this->assertNewAddressFields($billingAddressResponse);
$this->assertNewAddressFields($shippingAddressResponse, 'ShippingCartAddress');
}

/**
* Test case for deprecated `use_for_shipping` param.
*
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
Expand Down

0 comments on commit bb25f9a

Please sign in to comment.