Skip to content

Commit 13000a0

Browse files
committed
MC-22838: Required input type values validation does not work correctly
- Fix exception messages in GraphQl tests
1 parent 27a1e9b commit 13000a0

27 files changed

+100
-65
lines changed

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,19 @@ public function dataProviderTestPlaceOrder(): array
126126
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
127127
* @dataProvider dataProviderSetPaymentInvalidInput
128128
* @param \Closure $getMutationClosure
129-
* @param string $expectedMessage
129+
* @param array $expectedMessages
130130
* @expectedException \Exception
131131
*/
132-
public function testSetPaymentInvalidInput(\Closure $getMutationClosure, string $expectedMessage)
132+
public function testSetPaymentInvalidInput(\Closure $getMutationClosure, array $expectedMessages)
133133
{
134134
$reservedOrderId = 'test_quote';
135135
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId);
136136

137137
$setPaymentMutation = $getMutationClosure($maskedQuoteId);
138138

139-
$this->expectExceptionMessage($expectedMessage);
139+
foreach($expectedMessages as $expectedMessage){
140+
$this->expectExceptionMessage($expectedMessage);
141+
}
140142
$this->graphQlMutation($setPaymentMutation, [], '', $this->getHeaderMap());
141143
}
142144

@@ -152,13 +154,20 @@ public function dataProviderSetPaymentInvalidInput(): array
152154
function (string $maskedQuoteId) {
153155
return $this->getInvalidSetPaymentMutation($maskedQuoteId);
154156
},
155-
'Required parameter "authorizenet_acceptjs" for "payment_method" is missing.',
157+
[
158+
'Required parameter "authorizenet_acceptjs" for "payment_method" is missing.'
159+
]
156160
],
157161
[
158162
function (string $maskedQuoteId) {
159163
return $this->getEmptyAcceptJsInput($maskedQuoteId);
160164
},
161-
'for "authorizenet_acceptjs" is missing.',
165+
[
166+
'Field AuthorizenetInput.cc_last_4 of required type Int! was not provided.',
167+
'Field AuthorizenetInput.opaque_data_descriptor of required type String! was not provided.',
168+
'Field AuthorizenetInput.opaque_data_value of required type String! was not provided.'
169+
]
170+
162171
],
163172
[
164173
function (string $maskedQuoteId) {
@@ -168,13 +177,17 @@ function (string $maskedQuoteId) {
168177
static::VALID_NONCE
169178
);
170179
},
171-
'parameter "cc_last_4" for "authorizenet_acceptjs" is missing',
180+
[
181+
'Field AuthorizenetInput.cc_last_4 of required type Int! was not provided',
182+
]
172183
],
173184
[
174185
function (string $maskedQuoteId) {
175186
return $this->getMissingOpaqueDataValueAcceptJsInput($maskedQuoteId, static::VALID_DESCRIPTOR);
176187
},
177-
'parameter "opaque_data_value" for "authorizenet_acceptjs" is missing',
188+
[
189+
'Field AuthorizenetInput.opaque_data_value of required type String! was not provided',
190+
]
178191
],
179192
];
180193
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@ public function testSetPaymentMethodInvalidMethodInput(string $methodCode)
259259
$methodCode
260260
);
261261
$this->expectExceptionMessage("for \"$methodCode\" is missing.");
262+
$expectedExceptionMessages = [
263+
'braintree' =>
264+
'Field BraintreeInput.is_active_payment_token_enabler of required type Boolean! was not provided.',
265+
'braintree_cc_vault' =>
266+
'Field BraintreeCcVaultInput.public_hash of required type String! was not provided.'
267+
];
268+
269+
$this->expectExceptionMessage($expectedExceptionMessages[$methodCode]);
262270
$this->graphQlMutation($setPaymentQuery, [], '', $this->getHeaderMap());
263271
}
264272

@@ -277,7 +285,6 @@ public function testSetPaymentMethodInvalidMethodInput(string $methodCode)
277285
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
278286
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
279287
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
280-
* @dataProvider dataProviderTestSetPaymentMethodInvalidInput
281288
* @expectedException \Exception
282289
*/
283290
public function testSetPaymentMethodWithoutRequiredPaymentMethodInput()
@@ -286,7 +293,9 @@ public function testSetPaymentMethodWithoutRequiredPaymentMethodInput()
286293
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId);
287294

288295
$setPaymentQuery = $this->getSetPaymentBraintreeQueryInvalidPaymentMethodInput($maskedQuoteId);
289-
$this->expectExceptionMessage("for \"braintree\" is missing.");
296+
$this->expectExceptionMessage(
297+
'Field BraintreeInput.is_active_payment_token_enabler of required type Boolean! was not provided.'
298+
);
290299
$this->graphQlMutation($setPaymentQuery, [], '', $this->getHeaderMap());
291300
}
292301

dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Guest/SetPaymentMethodTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,14 @@ public function testSetPaymentMethodInvalidMethodInput()
151151
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId);
152152

153153
$setPaymentQuery = $this->getSetPaymentBraintreeQueryInvalidMethodInput($maskedQuoteId);
154-
$this->expectExceptionMessage("for \"braintree\" is missing.");
154+
155+
$this->expectExceptionMessage(
156+
'Field BraintreeInput.is_active_payment_token_enabler of required type Boolean! was not provided'
157+
);
158+
$this->expectExceptionMessage(
159+
'Field BraintreeInput.payment_method_nonce of required type String! was not provided.'
160+
);
161+
155162
$this->graphQlMutation($setPaymentQuery);
156163
}
157164

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function testAddSimpleProductToCart()
8585
/**
8686
* @magentoApiDataFixture Magento/Customer/_files/customer.php
8787
* @expectedException Exception
88-
* @expectedExceptionMessage Required parameter "cart_id" is missing
88+
* @expectedExceptionMessage Field AddSimpleProductsToCartInput.cart_id of required type String! was not provided.
8989
*/
9090
public function testAddSimpleProductToCartIfCartIdIsMissed()
9191
{
@@ -138,7 +138,6 @@ public function testAddSimpleProductToCartIfCartIdIsEmpty()
138138
/**
139139
* @magentoApiDataFixture Magento/Customer/_files/customer.php
140140
* @expectedException Exception
141-
* @expectedExceptionMessage Required parameter "cart_items" is missing
142141
*/
143142
public function testAddSimpleProductToCartIfCartItemsAreMissed()
144143
{
@@ -158,6 +157,11 @@ public function testAddSimpleProductToCartIfCartItemsAreMissed()
158157
}
159158
QUERY;
160159

160+
$this->expectExceptionMessage(
161+
'Field AddSimpleProductsToCartInput.cart_items of required type'
162+
. ' [SimpleProductCartItemInput]! was not provided.'
163+
);
164+
161165
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
162166
}
163167

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ public function dataProviderUpdateWithMissedRequiredParameters(): array
217217
return [
218218
'missed_cart_id' => [
219219
'coupon_code: "test"',
220-
'Required parameter "cart_id" is missing'
220+
'Field ApplyCouponToCartInput.cart_id of required type String! was not provided.'
221221
],
222222
'missed_coupon_code' => [
223223
'cart_id: "test_quote"',
224-
'Required parameter "coupon_code" is missing'
224+
'Field ApplyCouponToCartInput.coupon_code of required type String! was not provided.'
225225
],
226226
];
227227
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testPlaceOrderIfCartIdIsEmpty()
106106
/**
107107
* @magentoApiDataFixture Magento/Customer/_files/customer.php
108108
* @expectedException Exception
109-
* @expectedExceptionMessage Required parameter "cart_id" is missing
109+
* @expectedExceptionMessage Field PlaceOrderInput.cart_id of required type String! was not provided.
110110
*/
111111
public function testPlaceOrderIfCartIdIsMissed()
112112
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testRemoveCouponFromCartIfCartIdIsEmpty()
7373
/**
7474
* @magentoApiDataFixture Magento/Customer/_files/customer.php
7575
* @expectedException Exception
76-
* @expectedExceptionMessage Required parameter "cart_id" is missing
76+
* @expectedExceptionMessage Field RemoveCouponFromCartInput.cart_id of required type String! was not provided.
7777
*/
7878
public function testRemoveCouponFromCartIfCartIdIsMissed()
7979
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ public function dataProviderUpdateWithMissedRequiredParameters(): array
125125
return [
126126
'missed_cart_id' => [
127127
'cart_item_id: 1',
128-
'Required parameter "cart_id" is missing.'
128+
'Field RemoveItemFromCartInput.cart_id of required type String! was not provided.'
129129
],
130130
'missed_cart_item_id' => [
131131
'cart_id: "test_quote"',
132-
'Required parameter "cart_item_id" is missing.'
132+
'Field RemoveItemFromCartInput.cart_item_id of required type Int! was not provided.'
133133
],
134134
];
135135
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ public function dataProviderSetWithoutRequiredParameters(): array
660660
],
661661
'missed_cart_id' => [
662662
'billing_address: {}',
663-
'Required parameter "cart_id" is missing'
663+
'Field SetBillingAddressOnCartInput.cart_id of required type String! was not provided.'
664664
],
665665
'missed_region' => [
666666
'cart_id: "cart_id_value"

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,12 @@ public function dataProviderSetPaymentOnCartWithException(): array
136136
'payment_method: {
137137
code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '"
138138
}',
139-
'Required parameter "cart_id" is missing',
139+
'Field SetPaymentMethodAndPlaceOrderInput.cart_id of required type String! was not provided.',
140140
],
141141
'missed_payment_method' => [
142142
'cart_id: "cart_id_value"',
143-
'Required parameter "code" for "payment_method" is missing.',
143+
'Field SetPaymentMethodAndPlaceOrderInput.payment_method of required type PaymentMethodInput!'
144+
. ' was not provided.',
144145
],
145146
'place_order_with_out_of_stock_products' => [
146147
'cart_id: "cart_id_value"

0 commit comments

Comments
 (0)