|
34 | 34 | use Magento\TestFramework\Helper\Bootstrap; |
35 | 35 | use Magento\TestFramework\TestCase\GraphQl\ResponseContainsErrorsException; |
36 | 36 | use Magento\TestFramework\TestCase\GraphQlAbstract; |
| 37 | +use Magento\OfflinePayments\Model\Checkmo; |
37 | 38 |
|
38 | 39 | /** |
39 | 40 | * Test for placing an order for guest |
@@ -533,6 +534,56 @@ public function testPlaceOrderWithGiftMessage() |
533 | 534 | $this->assertNotEmpty($order->getGiftMessageId()); |
534 | 535 | } |
535 | 536 |
|
| 537 | + #[ |
| 538 | + Config('carriers/flatrate/active', '1', 'store', 'default'), |
| 539 | + Config('carriers/tablerate/active', '1', 'store', 'default'), |
| 540 | + Config('carriers/freeshipping/active', '1', 'store', 'default'), |
| 541 | + Config('payment/checkmo/active', '1', 'store', 'default'), |
| 542 | + DataFixture(ProductFixture::class, as: 'product'), |
| 543 | + DataFixture(Indexer::class, as: 'indexer'), |
| 544 | + DataFixture(GuestCartFixture::class, ['reserved_order_id' => 'test_quote'], as: 'cart'), |
| 545 | + DataFixture(SetGuestEmailFixture::class, ['cart_id' => '$cart.id$']), |
| 546 | + DataFixture(AddProductToCartFixture::class, ['cart_id' => '$cart.id$', 'product_id' => '$product.id$']), |
| 547 | + DataFixture(SetShippingAddressFixture::class, ['cart_id' => '$cart.id$']), |
| 548 | + DataFixture( |
| 549 | + SetPaymentMethodFixture::class, |
| 550 | + ['cart_id' => '$cart.id$', 'method' => Checkmo::PAYMENT_METHOD_CHECKMO_CODE] |
| 551 | + ), |
| 552 | + Config('payment/checkmo/active', '0', 'store', 'default'), |
| 553 | + ] |
| 554 | + public function testSetPreviouslyAddedPaymentMethodAfterItWasDisabled() |
| 555 | + { |
| 556 | + $cart = DataFixtureStorageManager::getStorage()->get('cart'); |
| 557 | + $maskedQuoteId = $this->quoteIdToMaskedQuoteIdInterface->execute((int)$cart->getId()); |
| 558 | + |
| 559 | + $query = $this->setPaymentMethodQuery($maskedQuoteId, Checkmo::PAYMENT_METHOD_CHECKMO_CODE); |
| 560 | + |
| 561 | + $this->expectException(\Exception::class); |
| 562 | + $this->expectExceptionMessage('The requested Payment Method is not available.'); |
| 563 | + $this->graphQlMutation($query); |
| 564 | + } |
| 565 | + |
| 566 | + /** |
| 567 | + * @param string $maskedQuoteId |
| 568 | + * @param string $methodCode |
| 569 | + * @return string |
| 570 | + */ |
| 571 | + private function setPaymentMethodQuery(string $maskedQuoteId, string $methodCode): string |
| 572 | + { |
| 573 | + return <<<QUERY |
| 574 | +mutation { |
| 575 | + setPaymentMethodOnCart(input: { |
| 576 | + cart_id: "{$maskedQuoteId}", |
| 577 | + payment_method: { code: "{$methodCode}" } |
| 578 | + }) { |
| 579 | + cart { |
| 580 | + selected_payment_method { code } |
| 581 | + } |
| 582 | + } |
| 583 | +} |
| 584 | +QUERY; |
| 585 | + } |
| 586 | + |
536 | 587 | /** |
537 | 588 | * @param string $maskedQuoteId |
538 | 589 | * @return string |
|
0 commit comments