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

#482: Adjusted test coverage for setting billing address #492

Merged
merged 4 commits into from
Mar 26, 2019
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 @@ -423,6 +423,39 @@ public function testSetBillingAddressOnNonExistentCart()
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
}

/**
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @dataProvider dataProviderSetWithoutRequiredParameters
* @param string $input
* @param string $message
* @throws \Exception
*/
public function testSetBillingAddressWithoutRequiredParameters(string $input, string $message)
{
$maskedQuoteId = $this->assignQuoteToCustomer();
$input = str_replace('cart_id_value', $maskedQuoteId, $input);

$query = <<<QUERY
mutation {
setBillingAddressOnCart(
input: {
{$input}
}
) {
cart {
billing_address {
city
}
}
}
}
QUERY;

$this->expectExceptionMessage($message);
$this->graphQlQuery($query);
}

/**
* Verify the all the whitelisted fields for a New Address Object
*
Expand Down Expand Up @@ -506,4 +539,22 @@ private function assignQuoteToCustomer(
$this->quoteResource->save($quote);
return $this->quoteIdToMaskedId->execute((int)$quote->getId());
}

/**
* @return array
*/
public function dataProviderSetWithoutRequiredParameters()
{
return [
'missed_billing_address' => [
'cart_id: "cart_id_value"',
'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput!'
. ' was not provided.',
],
'missed_cart_id' => [
'billing_address: {}',
'Required parameter "cart_id" is missing'
]
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,38 @@ public function testSetBillingAddressOnNonExistentCart()
$this->graphQlQuery($query);
}

/**
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
* @dataProvider dataProviderSetWithoutRequiredParameters
* @param string $input
* @param string $message
* @throws \Exception
*/
public function testSetBillingAddressWithoutRequiredParameters(string $input, string $message)
{
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_order_with_simple_product_without_address');
$input = str_replace('cart_id_value', $maskedQuoteId, $input);

$query = <<<QUERY
mutation {
setBillingAddressOnCart(
input: {
{$input}
}
) {
cart {
billing_address {
city
}
}
}
}
QUERY;

$this->expectExceptionMessage($message);
$this->graphQlQuery($query);
}

/**
* Verify the all the whitelisted fields for a New Address Object
*
Expand Down Expand Up @@ -297,4 +329,22 @@ private function getMaskedQuoteIdByReversedQuoteId(string $reversedQuoteId): str

return $this->quoteIdToMaskedId->execute((int)$quote->getId());
}

/**
* @return array
*/
public function dataProviderSetWithoutRequiredParameters()
{
return [
'missed_billing_address' => [
'cart_id: "cart_id_value"',
'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput!'
. ' was not provided.',
],
'missed_cart_id' => [
'billing_address: {}',
'Required parameter "cart_id" is missing'
]
];
}
}