Skip to content

Commit 26b8113

Browse files
committed
AC-9605: Place order with disabled Payment method working
1 parent 6b337ca commit 26b8113

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/PlaceOrderTest.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use Magento\TestFramework\Helper\Bootstrap;
3535
use Magento\TestFramework\TestCase\GraphQl\ResponseContainsErrorsException;
3636
use Magento\TestFramework\TestCase\GraphQlAbstract;
37+
use Magento\OfflinePayments\Model\Checkmo;
3738

3839
/**
3940
* Test for placing an order for guest
@@ -533,6 +534,56 @@ public function testPlaceOrderWithGiftMessage()
533534
$this->assertNotEmpty($order->getGiftMessageId());
534535
}
535536

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+
536587
/**
537588
* @param string $maskedQuoteId
538589
* @return string

0 commit comments

Comments
 (0)