Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

magento/graphql-ce#975: [Test coverage] Cover CartAddressTypeResolver #997

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,42 @@ public function testSetBillingAddressFromAddressBook()
$this->assertSavedBillingAddressFields($billingAddressResponse);
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/Customer/_files/customer_two_addresses.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 testVerifyBillingAddressType()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');

$query = <<<QUERY
mutation {
setBillingAddressOnCart(
input: {
cart_id: "$maskedQuoteId"
billing_address: {
customer_address_id: 1
}
}
) {
cart {
billing_address {
__typename
}
}
}
}
QUERY;

$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
$billingAddress = $response['setBillingAddressOnCart']['cart']['billing_address'];
self::assertArrayHasKey('__typename', $billingAddress);
self::assertEquals('BillingCartAddress', $billingAddress['__typename']);
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,44 @@ public function testSetShippingAddressFromAddressBook()

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/Customer/_files/customer_two_addresses.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 testVerifyShippingAddressType()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');

$query = <<<QUERY
mutation {
setShippingAddressesOnCart(
input: {
cart_id: "$maskedQuoteId"
shipping_addresses: [
{
customer_address_id: 1
}
]
}
) {
cart {
shipping_addresses {
__typename
}
}
}
}
QUERY;
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
$shippingAddresses = current($response['setShippingAddressesOnCart']['cart']['shipping_addresses']);
self::assertArrayHasKey('__typename', $shippingAddresses);
self::assertEquals('ShippingCartAddress', $shippingAddresses['__typename']);
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/Customer/_files/customer_address.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
Expand Down