Skip to content

Commit afae879

Browse files
committed
graphQl-987: [Test coverage] Cover exceptions in Magento\QuoteGraphQl\Model\Resolver\SetPaymentAndPlaceOrder
1 parent db0dce6 commit afae879

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,62 @@ public function testSetPaymentOnCartWithSimpleProduct()
8888
self::assertArrayHasKey('order_number', $response['placeOrder']['order']);
8989
}
9090

91+
/**
92+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
93+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
94+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
95+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
96+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
97+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
98+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
99+
*
100+
* @dataProvider dataProviderSetPaymentOnCartWithException
101+
* @param string $input
102+
* @param string $message
103+
* @throws \Exception
104+
*/
105+
public function testSetPaymentOnCartWithException(string $input, string $message)
106+
{
107+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
108+
$input = str_replace('cart_id_value', $maskedQuoteId, $input);
109+
110+
$query = <<<QUERY
111+
mutation {
112+
setPaymentMethodAndPlaceOrder(
113+
input: {
114+
{$input}
115+
}
116+
) {
117+
order {
118+
order_number
119+
}
120+
}
121+
}
122+
QUERY;
123+
124+
$this->expectExceptionMessage($message);
125+
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
126+
}
127+
128+
/**
129+
* @return array
130+
*/
131+
public function dataProviderSetPaymentOnCartWithException(): array
132+
{
133+
return [
134+
'missed_cart_id' => [
135+
'payment_method: {
136+
code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '"
137+
}',
138+
'Required parameter "cart_id" is missing',
139+
],
140+
'missed_payment_method' => [
141+
'cart_id: "cart_id_value"',
142+
'Required parameter "code" for "payment_method" is missing.',
143+
],
144+
];
145+
}
146+
91147
/**
92148
* @magentoApiDataFixture Magento/Customer/_files/customer.php
93149
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php

0 commit comments

Comments
 (0)