Skip to content

Commit

Permalink
ENGCOM-4574: #482: Adjusted test coverage for setting billing address #…
Browse files Browse the repository at this point in the history
…492

 - Merge Pull Request magento/graphql-ce#492 from sora1004/graphql-ce:magento2/graphql-ce_adjusted_test_coverage_set_billing_address
 - Merged commits:
   1. b5803c5
   2. 18cafdc
   3. eb2c414
   4. 594e556
  • Loading branch information
magento-engcom-team committed Mar 25, 2019
2 parents 677f1b6 + 594e556 commit 509b212
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
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'
]
];
}
}

0 comments on commit 509b212

Please sign in to comment.