Skip to content

Commit 5fcac84

Browse files
karyna-tlenaorobei
authored andcommitted
GraphQl Issue#1061 - Remove redundant logic from resolvers
1 parent 52b66ac commit 5fcac84

27 files changed

+1
-973
lines changed

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

Lines changed: 1 addition & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -157,38 +157,7 @@ function (string $maskedQuoteId) {
157157
[
158158
'Required parameter "authorizenet_acceptjs" for "payment_method" is missing.'
159159
]
160-
],
161-
[
162-
function (string $maskedQuoteId) {
163-
return $this->getEmptyAcceptJsInput($maskedQuoteId);
164-
},
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-
171-
],
172-
[
173-
function (string $maskedQuoteId) {
174-
return $this->getMissingCcLastFourAcceptJsInput(
175-
$maskedQuoteId,
176-
static::VALID_DESCRIPTOR,
177-
static::VALID_NONCE
178-
);
179-
},
180-
[
181-
'Field AuthorizenetInput.cc_last_4 of required type Int! was not provided',
182-
]
183-
],
184-
[
185-
function (string $maskedQuoteId) {
186-
return $this->getMissingOpaqueDataValueAcceptJsInput($maskedQuoteId, static::VALID_DESCRIPTOR);
187-
},
188-
[
189-
'Field AuthorizenetInput.opaque_data_value of required type String! was not provided',
190-
]
191-
],
160+
]
192161
];
193162
}
194163

@@ -218,93 +187,6 @@ private function getInvalidSetPaymentMutation(string $maskedQuoteId): string
218187
QUERY;
219188
}
220189

221-
/**
222-
* Get setPaymentMethodOnCart missing required additional data properties
223-
*
224-
* @param string $maskedQuoteId
225-
* @return string
226-
*/
227-
private function getEmptyAcceptJsInput(string $maskedQuoteId): string
228-
{
229-
return <<<QUERY
230-
mutation {
231-
setPaymentMethodOnCart(input:{
232-
cart_id:"{$maskedQuoteId}"
233-
payment_method:{
234-
code:"authorizenet_acceptjs"
235-
authorizenet_acceptjs: {}
236-
}
237-
}) {
238-
cart {
239-
selected_payment_method {
240-
code
241-
}
242-
}
243-
}
244-
}
245-
QUERY;
246-
}
247-
248-
/**
249-
* Get setPaymentMethodOnCart missing required additional data properties
250-
*
251-
* @param string $maskedQuoteId
252-
* @return string
253-
*/
254-
private function getMissingCcLastFourAcceptJsInput(string $maskedQuoteId, string $descriptor, string $nonce): string
255-
{
256-
return <<<QUERY
257-
mutation {
258-
setPaymentMethodOnCart(input:{
259-
cart_id:"{$maskedQuoteId}"
260-
payment_method:{
261-
code:"authorizenet_acceptjs"
262-
authorizenet_acceptjs:{
263-
opaque_data_descriptor: "{$descriptor}"
264-
opaque_data_value: "{$nonce}"
265-
}
266-
}
267-
}) {
268-
cart {
269-
selected_payment_method {
270-
code
271-
}
272-
}
273-
}
274-
}
275-
QUERY;
276-
}
277-
278-
/**
279-
* Get setPaymentMethodOnCart missing required additional data properties
280-
*
281-
* @param string $maskedQuoteId
282-
* @return string
283-
*/
284-
private function getMissingOpaqueDataValueAcceptJsInput(string $maskedQuoteId, string $descriptor): string
285-
{
286-
return <<<QUERY
287-
mutation {
288-
setPaymentMethodOnCart(input:{
289-
cart_id:"{$maskedQuoteId}"
290-
payment_method:{
291-
code:"authorizenet_acceptjs"
292-
authorizenet_acceptjs:{
293-
opaque_data_descriptor: "{$descriptor}"
294-
cc_last_4: 1111
295-
}
296-
}
297-
}) {
298-
cart {
299-
selected_payment_method {
300-
code
301-
}
302-
}
303-
}
304-
}
305-
QUERY;
306-
}
307-
308190
private function assertPlaceOrderResponse(array $response, string $reservedOrderId): void
309191
{
310192
self::assertArrayHasKey('placeOrder', $response);

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

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -270,35 +270,6 @@ public function testSetPaymentMethodInvalidMethodInput(string $methodCode)
270270
$this->graphQlMutation($setPaymentQuery, [], '', $this->getHeaderMap());
271271
}
272272

273-
/**
274-
* @magentoConfigFixture default_store carriers/flatrate/active 1
275-
* @magentoConfigFixture default_store payment/braintree/active 1
276-
* @magentoConfigFixture default_store payment/braintree_cc_vault/active 1
277-
* @magentoConfigFixture default_store payment/braintree/environment sandbox
278-
* @magentoConfigFixture default_store payment/braintree/merchant_id def_merchant_id
279-
* @magentoConfigFixture default_store payment/braintree/public_key def_public_key
280-
* @magentoConfigFixture default_store payment/braintree/private_key def_private_key
281-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
282-
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
283-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
284-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
285-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
286-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
287-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
288-
* @expectedException \Exception
289-
*/
290-
public function testSetPaymentMethodWithoutRequiredPaymentMethodInput()
291-
{
292-
$reservedOrderId = 'test_quote';
293-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId);
294-
295-
$setPaymentQuery = $this->getSetPaymentBraintreeQueryInvalidPaymentMethodInput($maskedQuoteId);
296-
$this->expectExceptionMessage(
297-
'Field BraintreeInput.is_active_payment_token_enabler of required type Boolean! was not provided.'
298-
);
299-
$this->graphQlMutation($setPaymentQuery, [], '', $this->getHeaderMap());
300-
}
301-
302273
public function dataProviderTestSetPaymentMethodInvalidInput(): array
303274
{
304275
return [

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

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -129,39 +129,6 @@ public function testSetPaymentMethodInvalidInput()
129129
$this->graphQlMutation($setPaymentQuery);
130130
}
131131

132-
/**
133-
* @magentoConfigFixture default_store carriers/flatrate/active 1
134-
* @magentoConfigFixture default_store payment/braintree/active 1
135-
* @magentoConfigFixture default_store payment/braintree/environment sandbox
136-
* @magentoConfigFixture default_store payment/braintree/merchant_id def_merchant_id
137-
* @magentoConfigFixture default_store payment/braintree/public_key def_public_key
138-
* @magentoConfigFixture default_store payment/braintree/private_key def_private_key
139-
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
140-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
141-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/set_guest_email.php
142-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
143-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
144-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
145-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
146-
* @expectedException \Exception
147-
*/
148-
public function testSetPaymentMethodInvalidMethodInput()
149-
{
150-
$reservedOrderId = 'test_quote';
151-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId);
152-
153-
$setPaymentQuery = $this->getSetPaymentBraintreeQueryInvalidMethodInput($maskedQuoteId);
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-
162-
$this->graphQlMutation($setPaymentQuery);
163-
}
164-
165132
private function assertPlaceOrderResponse(array $response, string $reservedOrderId): void
166133
{
167134
self::assertArrayHasKey('placeOrder', $response);

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

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -82,32 +82,6 @@ public function testAddSimpleProductToCart()
8282
self::assertEquals('USD', $rowTotalIncludingTax['currency']);
8383
}
8484

85-
/**
86-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
87-
* @expectedException Exception
88-
* @expectedExceptionMessage Field AddSimpleProductsToCartInput.cart_id of required type String! was not provided.
89-
*/
90-
public function testAddSimpleProductToCartIfCartIdIsMissed()
91-
{
92-
$query = <<<QUERY
93-
mutation {
94-
addSimpleProductsToCart(
95-
input: {
96-
cart_items: []
97-
}
98-
) {
99-
cart {
100-
items {
101-
id
102-
}
103-
}
104-
}
105-
}
106-
QUERY;
107-
108-
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
109-
}
110-
11185
/**
11286
* @magentoApiDataFixture Magento/Customer/_files/customer.php
11387
* @expectedException Exception
@@ -135,36 +109,6 @@ public function testAddSimpleProductToCartIfCartIdIsEmpty()
135109
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
136110
}
137111

138-
/**
139-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
140-
* @expectedException Exception
141-
*/
142-
public function testAddSimpleProductToCartIfCartItemsAreMissed()
143-
{
144-
$query = <<<QUERY
145-
mutation {
146-
addSimpleProductsToCart(
147-
input: {
148-
cart_id: "cart_id"
149-
}
150-
) {
151-
cart {
152-
items {
153-
id
154-
}
155-
}
156-
}
157-
}
158-
QUERY;
159-
160-
$this->expectExceptionMessage(
161-
'Field AddSimpleProductsToCartInput.cart_items of required type'
162-
. ' [SimpleProductCartItemInput]! was not provided.'
163-
);
164-
165-
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
166-
}
167-
168112
/**
169113
* @magentoApiDataFixture Magento/Customer/_files/customer.php
170114
* @expectedException Exception

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

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -54,32 +54,6 @@ public function testAddVirtualProductToCart()
5454
self::assertEquals($sku, $response['addVirtualProductsToCart']['cart']['items'][0]['product']['sku']);
5555
}
5656

57-
/**
58-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
59-
* @expectedException Exception
60-
* @expectedExceptionMessage Field AddSimpleProductsToCartInput.cart_id of required type String! was not provided.
61-
*/
62-
public function testAddVirtualProductToCartIfCartIdIsMissed()
63-
{
64-
$query = <<<QUERY
65-
mutation {
66-
addSimpleProductsToCart(
67-
input: {
68-
cart_items: []
69-
}
70-
) {
71-
cart {
72-
items {
73-
id
74-
}
75-
}
76-
}
77-
}
78-
QUERY;
79-
80-
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
81-
}
82-
8357
/**
8458
* @magentoApiDataFixture Magento/Customer/_files/customer.php
8559
* @expectedException Exception
@@ -107,35 +81,6 @@ public function testAddVirtualProductToCartIfCartIdIsEmpty()
10781
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
10882
}
10983

110-
/**
111-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
112-
*/
113-
public function testAddVirtualProductToCartIfCartItemsAreMissed()
114-
{
115-
$query = <<<QUERY
116-
mutation {
117-
addSimpleProductsToCart(
118-
input: {
119-
cart_id: "cart_id"
120-
}
121-
) {
122-
cart {
123-
items {
124-
id
125-
}
126-
}
127-
}
128-
}
129-
QUERY;
130-
$this->expectException(\Exception::class);
131-
$this->expectExceptionMessage(
132-
'Field AddSimpleProductsToCartInput.cart_items of required type [SimpleProductCartItemInput]!'
133-
. ' was not provided.'
134-
);
135-
136-
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
137-
}
138-
13984
/**
14085
* @magentoApiDataFixture Magento/Customer/_files/customer.php
14186
* @expectedException Exception

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

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -183,49 +183,6 @@ public function testApplyCouponWhichIsNotApplicable()
183183
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
184184
}
185185

186-
/**
187-
* @param string $input
188-
* @param string $message
189-
* @dataProvider dataProviderUpdateWithMissedRequiredParameters
190-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
191-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
192-
* @expectedException \Exception
193-
*/
194-
public function testApplyCouponWithMissedRequiredParameters(string $input, string $message)
195-
{
196-
$query = <<<QUERY
197-
mutation {
198-
applyCouponToCart(input: {{$input}}) {
199-
cart {
200-
applied_coupon {
201-
code
202-
}
203-
}
204-
}
205-
}
206-
QUERY;
207-
208-
$this->expectExceptionMessage($message);
209-
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
210-
}
211-
212-
/**
213-
* @return array
214-
*/
215-
public function dataProviderUpdateWithMissedRequiredParameters(): array
216-
{
217-
return [
218-
'missed_cart_id' => [
219-
'coupon_code: "test"',
220-
'Field ApplyCouponToCartInput.cart_id of required type String! was not provided.'
221-
],
222-
'missed_coupon_code' => [
223-
'cart_id: "test_quote"',
224-
'Field ApplyCouponToCartInput.coupon_code of required type String! was not provided.'
225-
],
226-
];
227-
}
228-
229186
/**
230187
* Retrieve customer authorization headers
231188
*

0 commit comments

Comments
 (0)