Skip to content

Commit e644f1f

Browse files
authored
ENGCOM-6055: graphQl-987: [Test coverage] Cover exceptions in Magento\QuoteGraphQl… #991
2 parents 055bd1a + 8ee5309 commit e644f1f

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,70 @@ 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+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/set_simple_product_out_of_stock.php
100+
*
101+
* @dataProvider dataProviderSetPaymentOnCartWithException
102+
* @param string $input
103+
* @param string $message
104+
* @throws \Exception
105+
*/
106+
public function testSetPaymentOnCartWithException(string $input, string $message)
107+
{
108+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
109+
$input = str_replace('cart_id_value', $maskedQuoteId, $input);
110+
111+
$query = <<<QUERY
112+
mutation {
113+
setPaymentMethodAndPlaceOrder(
114+
input: {
115+
{$input}
116+
}
117+
) {
118+
order {
119+
order_number
120+
}
121+
}
122+
}
123+
QUERY;
124+
125+
$this->expectExceptionMessage($message);
126+
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
127+
}
128+
129+
/**
130+
* @return array
131+
*/
132+
public function dataProviderSetPaymentOnCartWithException(): array
133+
{
134+
return [
135+
'missed_cart_id' => [
136+
'payment_method: {
137+
code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '"
138+
}',
139+
'Required parameter "cart_id" is missing',
140+
],
141+
'missed_payment_method' => [
142+
'cart_id: "cart_id_value"',
143+
'Required parameter "code" for "payment_method" is missing.',
144+
],
145+
'place_order_with_out_of_stock_products' => [
146+
'cart_id: "cart_id_value"
147+
payment_method: {
148+
code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '"
149+
}',
150+
'Unable to place order: Some of the products are out of stock.',
151+
],
152+
];
153+
}
154+
91155
/**
92156
* @magentoApiDataFixture Magento/Customer/_files/customer.php
93157
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php

0 commit comments

Comments
 (0)