-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Merge Pull Request magento/graphql-ce#983 from TomashKhamlai/graphql-ce:issue/981 - Merged commits: 1. 287e906
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
namespace Magento\GraphQl\Braintree\Customer; | ||
|
||
use Magento\Braintree\Gateway\Command\GetPaymentNonceCommand; | ||
use Magento\Framework\Exception\AuthenticationException; | ||
use Magento\Framework\Registry; | ||
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId; | ||
use Magento\Integration\Api\CustomerTokenServiceInterface; | ||
|
@@ -261,6 +262,34 @@ public function testSetPaymentMethodInvalidMethodInput(string $methodCode) | |
$this->graphQlMutation($setPaymentQuery, [], '', $this->getHeaderMap()); | ||
} | ||
|
||
/** | ||
* @magentoConfigFixture default_store carriers/flatrate/active 1 | ||
* @magentoConfigFixture default_store payment/braintree/active 1 | ||
* @magentoConfigFixture default_store payment/braintree_cc_vault/active 1 | ||
* @magentoConfigFixture default_store payment/braintree/environment sandbox | ||
* @magentoConfigFixture default_store payment/braintree/merchant_id def_merchant_id | ||
* @magentoConfigFixture default_store payment/braintree/public_key def_public_key | ||
* @magentoConfigFixture default_store payment/braintree/private_key def_private_key | ||
* @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 | ||
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php | ||
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php | ||
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php | ||
* @dataProvider dataProviderTestSetPaymentMethodInvalidInput | ||
* @expectedException \Exception | ||
*/ | ||
public function testSetPaymentMethodWithoutRequiredPaymentMethodInput() | ||
{ | ||
$reservedOrderId = 'test_quote'; | ||
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId); | ||
|
||
$setPaymentQuery = $this->getSetPaymentBraintreeQueryInvalidPaymentMethodInput($maskedQuoteId); | ||
$this->expectExceptionMessage("for \"braintree\" is missing."); | ||
$this->graphQlMutation($setPaymentQuery, [], '', $this->getHeaderMap()); | ||
} | ||
|
||
public function dataProviderTestSetPaymentMethodInvalidInput(): array | ||
{ | ||
return [ | ||
|
@@ -371,6 +400,33 @@ private function getSetPaymentBraintreeQueryInvalidInput(string $maskedQuoteId, | |
QUERY; | ||
} | ||
|
||
/** | ||
* @param string $maskedQuoteId | ||
* @return string | ||
*/ | ||
private function getSetPaymentBraintreeQueryInvalidPaymentMethodInput(string $maskedQuoteId): string | ||
{ | ||
return <<<QUERY | ||
mutation { | ||
setPaymentMethodOnCart(input:{ | ||
cart_id:"{$maskedQuoteId}" | ||
payment_method:{ | ||
code:"braintree" | ||
braintree:{ | ||
payment_method_nonce:"fake-valid-nonce" | ||
} | ||
} | ||
}) { | ||
cart { | ||
selected_payment_method { | ||
code | ||
} | ||
} | ||
} | ||
} | ||
QUERY; | ||
} | ||
|
||
/** | ||
* @param string $maskedQuoteId | ||
* @param string $methodCode | ||
|
@@ -437,7 +493,7 @@ private function getPaymentTokenQuery(): string | |
* @param string $username | ||
* @param string $password | ||
* @return array | ||
* @throws \Magento\Framework\Exception\AuthenticationException | ||
* @throws AuthenticationException | ||
*/ | ||
private function getHeaderMap(string $username = '[email protected]', string $password = 'password'): array | ||
{ | ||
|