From afae8793d87b7ac86d624febea141d1beca90f94 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Tue, 8 Oct 2019 11:26:09 +0300 Subject: [PATCH 1/2] graphQl-987: [Test coverage] Cover exceptions in Magento\QuoteGraphQl\Model\Resolver\SetPaymentAndPlaceOrder --- .../SetPaymentMethodAndPlaceOrderTest.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php index 981b2af6a9a00..fb543b87f7a70 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php @@ -88,6 +88,62 @@ public function testSetPaymentOnCartWithSimpleProduct() self::assertArrayHasKey('order_number', $response['placeOrder']['order']); } + /** + * @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 + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php + * + * @dataProvider dataProviderSetPaymentOnCartWithException + * @param string $input + * @param string $message + * @throws \Exception + */ + public function testSetPaymentOnCartWithException(string $input, string $message) + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + $input = str_replace('cart_id_value', $maskedQuoteId, $input); + + $query = <<expectExceptionMessage($message); + $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + } + + /** + * @return array + */ + public function dataProviderSetPaymentOnCartWithException(): array + { + return [ + 'missed_cart_id' => [ + 'payment_method: { + code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '" + }', + 'Required parameter "cart_id" is missing', + ], + 'missed_payment_method' => [ + 'cart_id: "cart_id_value"', + 'Required parameter "code" for "payment_method" is missing.', + ], + ]; + } + /** * @magentoApiDataFixture Magento/Customer/_files/customer.php * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php From d3850aa7465a4e398451358eb72c84ffe4fb1e62 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Tue, 8 Oct 2019 11:37:15 +0300 Subject: [PATCH 2/2] graphQl-987: [Test coverage] Cover exceptions in Magento\QuoteGraphQl\Model\Resolver\SetPaymentAndPlaceOrder --- .../Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php index fb543b87f7a70..aff124c522309 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php @@ -96,6 +96,7 @@ public function testSetPaymentOnCartWithSimpleProduct() * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/set_simple_product_out_of_stock.php * * @dataProvider dataProviderSetPaymentOnCartWithException * @param string $input @@ -141,6 +142,13 @@ public function dataProviderSetPaymentOnCartWithException(): array 'cart_id: "cart_id_value"', 'Required parameter "code" for "payment_method" is missing.', ], + 'place_order_with_out_of_stock_products' => [ + 'cart_id: "cart_id_value" + payment_method: { + code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '" + }', + 'Unable to place order: Some of the products are out of stock.', + ], ]; }