From d64082feabdc8ab356314a180ab1d3678c7d2973 Mon Sep 17 00:00:00 2001 From: Alex Taranovsky Date: Tue, 28 Jan 2020 13:19:30 +0200 Subject: [PATCH] magento/magento2#: Test Coverage. API functional tests. removeItemFromCart --- .../Quote/Customer/RemoveItemFromCartTest.php | 34 +++++++++++++++++++ .../Quote/Guest/RemoveItemFromCartTest.php | 32 +++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/RemoveItemFromCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/RemoveItemFromCartTest.php index c93db424834ef..b1a950bd76ca4 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/RemoveItemFromCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/RemoveItemFromCartTest.php @@ -155,6 +155,40 @@ public function testRemoveItemFromAnotherCustomerCart() $this->graphQlMutation($query, [], '', $this->getHeaderMap('customer2@search.example.com')); } + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + */ + public function testRemoveItemWithEmptyCartId() + { + $cartId = ""; + $cartItemId = $this->getQuoteItemIdByReservedQuoteIdAndSku->execute('test_quote', 'simple_product'); + + $this->expectExceptionMessage("Required parameter \"cart_id\" is missing."); + + $query = $this->getQuery($cartId, $cartItemId); + $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + } + + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + */ + public function testRemoveItemWithZeroCartItemId() + { + $cartId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + $cartItemId = 0; + + $this->expectExceptionMessage("Required parameter \"cart_item_id\" is missing."); + + $query = $this->getQuery($cartId, $cartItemId); + $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + } + /** * @param string $maskedQuoteId * @param int $itemId diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveItemFromCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveItemFromCartTest.php index 6f105259bf65c..931819af781d5 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveItemFromCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveItemFromCartTest.php @@ -119,6 +119,38 @@ public function testRemoveItemFromCustomerCart() $this->graphQlMutation($query); } + /** + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + */ + public function testRemoveItemWithEmptyCartId() + { + $cartId = ""; + $cartItemId = $this->getQuoteItemIdByReservedQuoteIdAndSku->execute('test_quote', 'simple_product'); + + $this->expectExceptionMessage("Required parameter \"cart_id\" is missing."); + + $query = $this->getQuery($cartId, $cartItemId); + $this->graphQlMutation($query); + } + + /** + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + */ + public function testRemoveItemWithZeroCartItemId() + { + $cartId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + $cartItemId = 0; + + $this->expectExceptionMessage("Required parameter \"cart_item_id\" is missing."); + + $query = $this->getQuery($cartId, $cartItemId); + $this->graphQlMutation($query); + } + /** * @param string $maskedQuoteId * @param int $itemId