|
8 | 8 | namespace Magento\GraphQl\Braintree\Customer;
|
9 | 9 |
|
10 | 10 | use Magento\Braintree\Gateway\Command\GetPaymentNonceCommand;
|
| 11 | +use Magento\Framework\Exception\AuthenticationException; |
11 | 12 | use Magento\Framework\Registry;
|
12 | 13 | use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
|
13 | 14 | use Magento\Integration\Api\CustomerTokenServiceInterface;
|
@@ -261,6 +262,34 @@ public function testSetPaymentMethodInvalidMethodInput(string $methodCode)
|
261 | 262 | $this->graphQlMutation($setPaymentQuery, [], '', $this->getHeaderMap());
|
262 | 263 | }
|
263 | 264 |
|
| 265 | + /** |
| 266 | + * @magentoConfigFixture default_store carriers/flatrate/active 1 |
| 267 | + * @magentoConfigFixture default_store payment/braintree/active 1 |
| 268 | + * @magentoConfigFixture default_store payment/braintree_cc_vault/active 1 |
| 269 | + * @magentoConfigFixture default_store payment/braintree/environment sandbox |
| 270 | + * @magentoConfigFixture default_store payment/braintree/merchant_id def_merchant_id |
| 271 | + * @magentoConfigFixture default_store payment/braintree/public_key def_public_key |
| 272 | + * @magentoConfigFixture default_store payment/braintree/private_key def_private_key |
| 273 | + * @magentoApiDataFixture Magento/Customer/_files/customer.php |
| 274 | + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php |
| 275 | + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php |
| 276 | + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php |
| 277 | + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php |
| 278 | + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php |
| 279 | + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php |
| 280 | + * @dataProvider dataProviderTestSetPaymentMethodInvalidInput |
| 281 | + * @expectedException \Exception |
| 282 | + */ |
| 283 | + public function testSetPaymentMethodWithoutRequiredPaymentMethodInput() |
| 284 | + { |
| 285 | + $reservedOrderId = 'test_quote'; |
| 286 | + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId); |
| 287 | + |
| 288 | + $setPaymentQuery = $this->getSetPaymentBraintreeQueryInvalidPaymentMethodInput($maskedQuoteId); |
| 289 | + $this->expectExceptionMessage("for \"braintree\" is missing."); |
| 290 | + $this->graphQlMutation($setPaymentQuery, [], '', $this->getHeaderMap()); |
| 291 | + } |
| 292 | + |
264 | 293 | public function dataProviderTestSetPaymentMethodInvalidInput(): array
|
265 | 294 | {
|
266 | 295 | return [
|
@@ -371,6 +400,33 @@ private function getSetPaymentBraintreeQueryInvalidInput(string $maskedQuoteId,
|
371 | 400 | QUERY;
|
372 | 401 | }
|
373 | 402 |
|
| 403 | + /** |
| 404 | + * @param string $maskedQuoteId |
| 405 | + * @return string |
| 406 | + */ |
| 407 | + private function getSetPaymentBraintreeQueryInvalidPaymentMethodInput(string $maskedQuoteId): string |
| 408 | + { |
| 409 | + return <<<QUERY |
| 410 | +mutation { |
| 411 | + setPaymentMethodOnCart(input:{ |
| 412 | + cart_id:"{$maskedQuoteId}" |
| 413 | + payment_method:{ |
| 414 | + code:"braintree" |
| 415 | + braintree:{ |
| 416 | + payment_method_nonce:"fake-valid-nonce" |
| 417 | + } |
| 418 | + } |
| 419 | + }) { |
| 420 | + cart { |
| 421 | + selected_payment_method { |
| 422 | + code |
| 423 | + } |
| 424 | + } |
| 425 | + } |
| 426 | +} |
| 427 | +QUERY; |
| 428 | + } |
| 429 | + |
374 | 430 | /**
|
375 | 431 | * @param string $maskedQuoteId
|
376 | 432 | * @param string $methodCode
|
@@ -437,7 +493,7 @@ private function getPaymentTokenQuery(): string
|
437 | 493 | * @param string $username
|
438 | 494 | * @param string $password
|
439 | 495 | * @return array
|
440 |
| - * @throws \Magento\Framework\Exception\AuthenticationException |
| 496 | + * @throws AuthenticationException |
441 | 497 | */
|
442 | 498 | private function getHeaderMap( string $username = '[email protected]', string $password = 'password'): array
|
443 | 499 | {
|
|
0 commit comments