Skip to content

Commit 01fef01

Browse files
authored
ENGCOM-5982: Improve test coverage for Magento\AuthorizenetGraphQl\Model\AuthorizenetDataProvider #976
2 parents f45b0c1 + bf21283 commit 01fef01

File tree

1 file changed

+80
-4
lines changed

1 file changed

+80
-4
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Customer/SetPaymentMethodTest.php

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,25 @@ function (string $maskedQuoteId) {
156156
],
157157
[
158158
function (string $maskedQuoteId) {
159-
return $this->getInvalidAcceptJsInput($maskedQuoteId);
159+
return $this->getEmptyAcceptJsInput($maskedQuoteId);
160160
},
161-
'for "authorizenet_acceptjs" is missing.'
161+
'for "authorizenet_acceptjs" is missing.',
162+
],
163+
[
164+
function (string $maskedQuoteId) {
165+
return $this->getMissingCcLastFourAcceptJsInput(
166+
$maskedQuoteId,
167+
static::VALID_DESCRIPTOR,
168+
static::VALID_NONCE
169+
);
170+
},
171+
'parameter "cc_last_4" for "authorizenet_acceptjs" is missing',
172+
],
173+
[
174+
function (string $maskedQuoteId) {
175+
return $this->getMissingOpaqueDataValueAcceptJsInput($maskedQuoteId, static::VALID_DESCRIPTOR);
176+
},
177+
'parameter "opaque_data_value" for "authorizenet_acceptjs" is missing',
162178
],
163179
];
164180
}
@@ -190,12 +206,12 @@ private function getInvalidSetPaymentMutation(string $maskedQuoteId): string
190206
}
191207

192208
/**
193-
* Get setPaymentMethodOnCart missing require additional data properties
209+
* Get setPaymentMethodOnCart missing required additional data properties
194210
*
195211
* @param string $maskedQuoteId
196212
* @return string
197213
*/
198-
private function getInvalidAcceptJsInput(string $maskedQuoteId): string
214+
private function getEmptyAcceptJsInput(string $maskedQuoteId): string
199215
{
200216
return <<<QUERY
201217
mutation {
@@ -216,6 +232,66 @@ private function getInvalidAcceptJsInput(string $maskedQuoteId): string
216232
QUERY;
217233
}
218234

235+
/**
236+
* Get setPaymentMethodOnCart missing required additional data properties
237+
*
238+
* @param string $maskedQuoteId
239+
* @return string
240+
*/
241+
private function getMissingCcLastFourAcceptJsInput(string $maskedQuoteId, string $descriptor, string $nonce): string
242+
{
243+
return <<<QUERY
244+
mutation {
245+
setPaymentMethodOnCart(input:{
246+
cart_id:"{$maskedQuoteId}"
247+
payment_method:{
248+
code:"authorizenet_acceptjs"
249+
authorizenet_acceptjs:{
250+
opaque_data_descriptor: "{$descriptor}"
251+
opaque_data_value: "{$nonce}"
252+
}
253+
}
254+
}) {
255+
cart {
256+
selected_payment_method {
257+
code
258+
}
259+
}
260+
}
261+
}
262+
QUERY;
263+
}
264+
265+
/**
266+
* Get setPaymentMethodOnCart missing required additional data properties
267+
*
268+
* @param string $maskedQuoteId
269+
* @return string
270+
*/
271+
private function getMissingOpaqueDataValueAcceptJsInput(string $maskedQuoteId, string $descriptor): string
272+
{
273+
return <<<QUERY
274+
mutation {
275+
setPaymentMethodOnCart(input:{
276+
cart_id:"{$maskedQuoteId}"
277+
payment_method:{
278+
code:"authorizenet_acceptjs"
279+
authorizenet_acceptjs:{
280+
opaque_data_descriptor: "{$descriptor}"
281+
cc_last_4: 1111
282+
}
283+
}
284+
}) {
285+
cart {
286+
selected_payment_method {
287+
code
288+
}
289+
}
290+
}
291+
}
292+
QUERY;
293+
}
294+
219295
private function assertPlaceOrderResponse(array $response, string $reservedOrderId): void
220296
{
221297
self::assertArrayHasKey('placeOrder', $response);

0 commit comments

Comments
 (0)