@@ -88,6 +88,62 @@ public function testSetPaymentOnCartWithSimpleProduct()
88
88
self ::assertArrayHasKey ('order_number ' , $ response ['placeOrder ' ]['order ' ]);
89
89
}
90
90
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
+
91
147
/**
92
148
* @magentoApiDataFixture Magento/Customer/_files/customer.php
93
149
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
0 commit comments