From 990a373803fc004b5da6bd20ca9d3149744a9f42 Mon Sep 17 00:00:00 2001 From: Alex Taranovsky Date: Wed, 6 Mar 2019 12:38:37 +0200 Subject: [PATCH 1/2] 429 - Test coverage: nonExistentCart 1. Add none existing cart test - Could not find a cart with ID "non_existent_masked_id" --- .../Customer/SetBillingAddressOnCartTest.php | 34 +++++++++++++++++++ .../Customer/SetPaymentMethodOnCartTest.php | 34 +++++++++++++++++++ .../Guest/SetBillingAddressOnCartTest.php | 33 ++++++++++++++++++ .../Guest/SetPaymentMethodOnCartTest.php | 33 ++++++++++++++++++ 4 files changed, 134 insertions(+) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php index 1a93c011e80a..06926e0a0b2e 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php @@ -403,6 +403,40 @@ public function testSetBillingAddressIfCustomerIsNotOwnerOfAddress() $this->graphQlQuery($query, [], '', $this->getHeaderMap('customer2@search.example.com')); } + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @expectedException \Exception + * @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id" + */ + public function testSetBillingAddressOnNonExistentCart() + { + $maskedQuoteId = 'non_existent_masked_id'; + $query = $this->getCartQuery($maskedQuoteId); + $this->graphQlQuery($query, [], '', $this->getHeaderMap()); + } + + /** + * @param string $maskedQuoteId + * @return string + */ + private function getCartQuery( + string $maskedQuoteId + ) : string { + return <<graphQlQuery($query, [], '', $this->getHeaderMap('customer2@search.example.com')); } + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @expectedException \Exception + * @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id" + */ + public function testPaymentMethodOnNonExistentCart() + { + $maskedQuoteId = 'non_existent_masked_id'; + $query = $this->getCartQuery($maskedQuoteId); + $this->graphQlQuery($query, [], '', $this->getHeaderMap()); + } + + /** + * @param string $maskedQuoteId + * @return string + */ + private function getCartQuery( + string $maskedQuoteId + ) : string { + return <<graphQlQuery($query); } + /** + * @expectedException \Exception + * @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id" + */ + public function testSetBillingAddressOnNonExistentCart() + { + $maskedQuoteId = 'non_existent_masked_id'; + $query = $this->getCartQuery($maskedQuoteId); + $this->graphQlQuery($query); + } + + /** + * @param string $maskedQuoteId + * @return string + */ + private function getCartQuery( + string $maskedQuoteId + ) : string { + return <<graphQlQuery($query); } + /** + * @expectedException \Exception + * @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id" + */ + public function testSetPaymentOnNonExistentCart() + { + $maskedQuoteId = 'non_existent_masked_id'; + $query = $this->getCartQuery($maskedQuoteId); + $this->graphQlQuery($query); + } + /** * @param string $maskedQuoteId * @param string $methodCode @@ -155,6 +166,28 @@ private function prepareMutationQuery( QUERY; } + /** + * @param string $maskedQuoteId + * @return string + */ + private function getCartQuery( + string $maskedQuoteId + ) : string { + return << Date: Tue, 12 Mar 2019 17:25:53 -0500 Subject: [PATCH 2/2] GraphQL-429: Test coverage: nonExistentCart --- .../Customer/SetBillingAddressOnCartTest.php | 18 ++--------- .../Customer/SetPaymentMethodOnCartTest.php | 18 ++--------- .../Guest/SetBillingAddressOnCartTest.php | 18 ++--------- .../Guest/SetPaymentMethodOnCartTest.php | 32 ++++++------------- 4 files changed, 15 insertions(+), 71 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php index 06926e0a0b2e..ccd328cea12e 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php @@ -411,30 +411,16 @@ public function testSetBillingAddressIfCustomerIsNotOwnerOfAddress() public function testSetBillingAddressOnNonExistentCart() { $maskedQuoteId = 'non_existent_masked_id'; - $query = $this->getCartQuery($maskedQuoteId); - $this->graphQlQuery($query, [], '', $this->getHeaderMap()); - } - - /** - * @param string $maskedQuoteId - * @return string - */ - private function getCartQuery( - string $maskedQuoteId - ) : string { - return <<graphQlQuery($query, [], '', $this->getHeaderMap()); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodOnCartTest.php index a2bbbfe135fa..91c98d2f13f4 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodOnCartTest.php @@ -159,30 +159,16 @@ public function testSetPaymentMethodToAnotherCustomerCart() public function testPaymentMethodOnNonExistentCart() { $maskedQuoteId = 'non_existent_masked_id'; - $query = $this->getCartQuery($maskedQuoteId); - $this->graphQlQuery($query, [], '', $this->getHeaderMap()); - } - - /** - * @param string $maskedQuoteId - * @return string - */ - private function getCartQuery( - string $maskedQuoteId - ) : string { - return <<graphQlQuery($query, [], '', $this->getHeaderMap()); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php index 0bb7c9741197..8f8e5419a9ff 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php @@ -251,30 +251,16 @@ public function testSetBillingAddressFromAddressBook() public function testSetBillingAddressOnNonExistentCart() { $maskedQuoteId = 'non_existent_masked_id'; - $query = $this->getCartQuery($maskedQuoteId); - $this->graphQlQuery($query); - } - - /** - * @param string $maskedQuoteId - * @return string - */ - private function getCartQuery( - string $maskedQuoteId - ) : string { - return <<graphQlQuery($query); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetPaymentMethodOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetPaymentMethodOnCartTest.php index 5117fce04a91..fbfa53b7d643 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetPaymentMethodOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetPaymentMethodOnCartTest.php @@ -133,7 +133,15 @@ public function testSetPaymentMethodToCustomerCart() public function testSetPaymentOnNonExistentCart() { $maskedQuoteId = 'non_existent_masked_id'; - $query = $this->getCartQuery($maskedQuoteId); + $query = <<graphQlQuery($query); } @@ -166,28 +174,6 @@ private function prepareMutationQuery( QUERY; } - /** - * @param string $maskedQuoteId - * @return string - */ - private function getCartQuery( - string $maskedQuoteId - ) : string { - return <<