Skip to content

Commit 3eb351a

Browse files
authored
ENGCOM-4574: #482: Adjusted test coverage for setting billing address #492
2 parents 4f0bf65 + 509b212 commit 3eb351a

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,39 @@ public function testSetBillingAddressOnNonExistentCart()
423423
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
424424
}
425425

426+
/**
427+
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
428+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
429+
* @dataProvider dataProviderSetWithoutRequiredParameters
430+
* @param string $input
431+
* @param string $message
432+
* @throws \Exception
433+
*/
434+
public function testSetBillingAddressWithoutRequiredParameters(string $input, string $message)
435+
{
436+
$maskedQuoteId = $this->assignQuoteToCustomer();
437+
$input = str_replace('cart_id_value', $maskedQuoteId, $input);
438+
439+
$query = <<<QUERY
440+
mutation {
441+
setBillingAddressOnCart(
442+
input: {
443+
{$input}
444+
}
445+
) {
446+
cart {
447+
billing_address {
448+
city
449+
}
450+
}
451+
}
452+
}
453+
QUERY;
454+
455+
$this->expectExceptionMessage($message);
456+
$this->graphQlQuery($query);
457+
}
458+
426459
/**
427460
* Verify the all the whitelisted fields for a New Address Object
428461
*
@@ -506,4 +539,22 @@ private function assignQuoteToCustomer(
506539
$this->quoteResource->save($quote);
507540
return $this->quoteIdToMaskedId->execute((int)$quote->getId());
508541
}
542+
543+
/**
544+
* @return array
545+
*/
546+
public function dataProviderSetWithoutRequiredParameters()
547+
{
548+
return [
549+
'missed_billing_address' => [
550+
'cart_id: "cart_id_value"',
551+
'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput!'
552+
. ' was not provided.',
553+
],
554+
'missed_cart_id' => [
555+
'billing_address: {}',
556+
'Required parameter "cart_id" is missing'
557+
]
558+
];
559+
}
509560
}

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,38 @@ public function testSetBillingAddressOnNonExistentCart()
263263
$this->graphQlQuery($query);
264264
}
265265

266+
/**
267+
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
268+
* @dataProvider dataProviderSetWithoutRequiredParameters
269+
* @param string $input
270+
* @param string $message
271+
* @throws \Exception
272+
*/
273+
public function testSetBillingAddressWithoutRequiredParameters(string $input, string $message)
274+
{
275+
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_order_with_simple_product_without_address');
276+
$input = str_replace('cart_id_value', $maskedQuoteId, $input);
277+
278+
$query = <<<QUERY
279+
mutation {
280+
setBillingAddressOnCart(
281+
input: {
282+
{$input}
283+
}
284+
) {
285+
cart {
286+
billing_address {
287+
city
288+
}
289+
}
290+
}
291+
}
292+
QUERY;
293+
294+
$this->expectExceptionMessage($message);
295+
$this->graphQlQuery($query);
296+
}
297+
266298
/**
267299
* Verify the all the whitelisted fields for a New Address Object
268300
*
@@ -297,4 +329,22 @@ private function getMaskedQuoteIdByReversedQuoteId(string $reversedQuoteId): str
297329

298330
return $this->quoteIdToMaskedId->execute((int)$quote->getId());
299331
}
332+
333+
/**
334+
* @return array
335+
*/
336+
public function dataProviderSetWithoutRequiredParameters()
337+
{
338+
return [
339+
'missed_billing_address' => [
340+
'cart_id: "cart_id_value"',
341+
'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput!'
342+
. ' was not provided.',
343+
],
344+
'missed_cart_id' => [
345+
'billing_address: {}',
346+
'Required parameter "cart_id" is missing'
347+
]
348+
];
349+
}
300350
}

0 commit comments

Comments
 (0)