@@ -109,6 +109,113 @@ public function dataProviderTestPlaceOrder(): array
109
109
];
110
110
}
111
111
112
+ /**
113
+ * @magentoConfigFixture default_store carriers/flatrate/active 1
114
+ * @magentoConfigFixture default_store payment/authorizenet_acceptjs/active 1
115
+ * @magentoConfigFixture default_store payment/authorizenet_acceptjs/environment sandbox
116
+ * @magentoConfigFixture default_store payment/authorizenet_acceptjs/login def_login
117
+ * @magentoConfigFixture default_store payment/authorizenet_acceptjs/trans_key def_trans_key
118
+ * @magentoConfigFixture default_store payment/authorizenet_acceptjs/public_client_key def_public_client_key
119
+ * @magentoConfigFixture default_store payment/authorizenet_acceptjs/trans_signature_key def_trans_signature_key
120
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
121
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
122
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
123
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
124
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
125
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
126
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
127
+ * @dataProvider dataProviderSetPaymentInvalidInput
128
+ * @param \Closure $getMutationClosure
129
+ * @param string $expectedMessage
130
+ * @expectedException \Exception
131
+ */
132
+ public function testSetPaymentInvalidInput (\Closure $ getMutationClosure , string $ expectedMessage )
133
+ {
134
+ $ reservedOrderId = 'test_quote ' ;
135
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ($ reservedOrderId );
136
+
137
+ $ setPaymentMutation = $ getMutationClosure ($ maskedQuoteId );
138
+
139
+ $ this ->expectExceptionMessage ($ expectedMessage );
140
+ $ this ->graphQlMutation ($ setPaymentMutation , [], '' , $ this ->getHeaderMap ());
141
+ }
142
+
143
+ /**
144
+ * Data provider for testSetPaymentInvalidInput
145
+ *
146
+ * @return array
147
+ */
148
+ public function dataProviderSetPaymentInvalidInput (): array
149
+ {
150
+ return [
151
+ [
152
+ function (string $ maskedQuoteId ) {
153
+ return $ this ->getInvalidSetPaymentMutation ($ maskedQuoteId );
154
+ },
155
+ 'Required parameter "authorizenet_acceptjs" for "payment_method" is missing. ' ,
156
+ ],
157
+ [
158
+ function (string $ maskedQuoteId ) {
159
+ return $ this ->getInvalidAcceptJsInput ($ maskedQuoteId );
160
+ },
161
+ 'for "authorizenet_acceptjs" is missing. '
162
+ ],
163
+ ];
164
+ }
165
+
166
+ /**
167
+ * Get setPaymentMethodOnCart missing additional data property
168
+ *
169
+ * @param string $maskedQuoteId
170
+ * @return string
171
+ */
172
+ private function getInvalidSetPaymentMutation (string $ maskedQuoteId ): string
173
+ {
174
+ return <<<QUERY
175
+ mutation {
176
+ setPaymentMethodOnCart(input:{
177
+ cart_id:" {$ maskedQuoteId }"
178
+ payment_method:{
179
+ code:"authorizenet_acceptjs"
180
+ }
181
+ }) {
182
+ cart {
183
+ selected_payment_method {
184
+ code
185
+ }
186
+ }
187
+ }
188
+ }
189
+ QUERY ;
190
+ }
191
+
192
+ /**
193
+ * Get setPaymentMethodOnCart missing require additional data properties
194
+ *
195
+ * @param string $maskedQuoteId
196
+ * @return string
197
+ */
198
+ private function getInvalidAcceptJsInput (string $ maskedQuoteId ): string
199
+ {
200
+ return <<<QUERY
201
+ mutation {
202
+ setPaymentMethodOnCart(input:{
203
+ cart_id:" {$ maskedQuoteId }"
204
+ payment_method:{
205
+ code:"authorizenet_acceptjs"
206
+ authorizenet_acceptjs: {}
207
+ }
208
+ }) {
209
+ cart {
210
+ selected_payment_method {
211
+ code
212
+ }
213
+ }
214
+ }
215
+ }
216
+ QUERY ;
217
+ }
218
+
112
219
private function assertPlaceOrderResponse (array $ response , string $ reservedOrderId ): void
113
220
{
114
221
self ::assertArrayHasKey ('placeOrder ' , $ response );
0 commit comments