Skip to content

Commit 207100a

Browse files
authored
ENGCOM-6053: magento/graphql-ce#975: [Test coverage] Cover CartAddressTypeResolver #997
2 parents 268edd9 + 10e5bcb commit 207100a

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,42 @@ public function testSetBillingAddressFromAddressBook()
256256
$this->assertSavedBillingAddressFields($billingAddressResponse);
257257
}
258258

259+
/**
260+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
261+
* @magentoApiDataFixture Magento/Customer/_files/customer_two_addresses.php
262+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
263+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
264+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
265+
*/
266+
public function testVerifyBillingAddressType()
267+
{
268+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
269+
270+
$query = <<<QUERY
271+
mutation {
272+
setBillingAddressOnCart(
273+
input: {
274+
cart_id: "$maskedQuoteId"
275+
billing_address: {
276+
customer_address_id: 1
277+
}
278+
}
279+
) {
280+
cart {
281+
billing_address {
282+
__typename
283+
}
284+
}
285+
}
286+
}
287+
QUERY;
288+
289+
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
290+
$billingAddress = $response['setBillingAddressOnCart']['cart']['billing_address'];
291+
self::assertArrayHasKey('__typename', $billingAddress);
292+
self::assertEquals('BillingCartAddress', $billingAddress['__typename']);
293+
}
294+
259295
/**
260296
* @magentoApiDataFixture Magento/Customer/_files/customer.php
261297
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,44 @@ public function testSetShippingAddressFromAddressBook()
232232

233233
/**
234234
* @magentoApiDataFixture Magento/Customer/_files/customer.php
235+
* @magentoApiDataFixture Magento/Customer/_files/customer_two_addresses.php
236+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
237+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
238+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
239+
*/
240+
public function testVerifyShippingAddressType()
241+
{
242+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
243+
244+
$query = <<<QUERY
245+
mutation {
246+
setShippingAddressesOnCart(
247+
input: {
248+
cart_id: "$maskedQuoteId"
249+
shipping_addresses: [
250+
{
251+
customer_address_id: 1
252+
}
253+
]
254+
}
255+
) {
256+
cart {
257+
shipping_addresses {
258+
__typename
259+
}
260+
}
261+
}
262+
}
263+
QUERY;
264+
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
265+
$shippingAddresses = current($response['setShippingAddressesOnCart']['cart']['shipping_addresses']);
266+
self::assertArrayHasKey('__typename', $shippingAddresses);
267+
self::assertEquals('ShippingCartAddress', $shippingAddresses['__typename']);
268+
}
269+
270+
/**
271+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
272+
* @magentoApiDataFixture Magento/Customer/_files/customer_address.php
235273
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
236274
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
237275
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php

0 commit comments

Comments
 (0)