From 9dee0e111dc25b3ea45619370b876014ca855f0d Mon Sep 17 00:00:00 2001 From: Ievgenii Gryshkun Date: Tue, 12 Mar 2019 07:59:18 +0200 Subject: [PATCH 01/13] Currency misspelled in graphql attributes --- app/code/Magento/DirectoryGraphQl/etc/schema.graphqls | 4 ++-- .../testsuite/Magento/GraphQl/Directory/CurrencyTest.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/DirectoryGraphQl/etc/schema.graphqls b/app/code/Magento/DirectoryGraphQl/etc/schema.graphqls index 40ef6975fad8b..f2bc576f95e8e 100644 --- a/app/code/Magento/DirectoryGraphQl/etc/schema.graphqls +++ b/app/code/Magento/DirectoryGraphQl/etc/schema.graphqls @@ -10,8 +10,8 @@ type Query { type Currency { base_currency_code: String base_currency_symbol: String - default_display_currecy_code: String - default_display_currecy_symbol: String + default_display_currency_code: String + default_display_currency_symbol: String available_currency_codes: [String] exchange_rates: [ExchangeRate] } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Directory/CurrencyTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Directory/CurrencyTest.php index 1ff0b53dda0bb..ad5d71cb08605 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Directory/CurrencyTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Directory/CurrencyTest.php @@ -21,8 +21,8 @@ public function testGetCurrency() currency { base_currency_code base_currency_symbol - default_display_currecy_code - default_display_currecy_symbol + default_display_currency_code + default_display_currency_symbol available_currency_codes exchange_rates { currency_to @@ -36,8 +36,8 @@ public function testGetCurrency() $this->assertArrayHasKey('currency', $result); $this->assertArrayHasKey('base_currency_code', $result['currency']); $this->assertArrayHasKey('base_currency_symbol', $result['currency']); - $this->assertArrayHasKey('default_display_currecy_code', $result['currency']); - $this->assertArrayHasKey('default_display_currecy_symbol', $result['currency']); + $this->assertArrayHasKey('default_display_currency_code', $result['currency']); + $this->assertArrayHasKey('default_display_currency_symbol', $result['currency']); $this->assertArrayHasKey('available_currency_codes', $result['currency']); $this->assertArrayHasKey('exchange_rates', $result['currency']); } From bfea663290be803d2ced87e55376790a27d47001 Mon Sep 17 00:00:00 2001 From: Ievgenii Gryshkun Date: Wed, 13 Mar 2019 09:53:22 +0200 Subject: [PATCH 02/13] Currency misspelled in graphql attributes --- app/code/Magento/DirectoryGraphQl/etc/schema.graphqls | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/DirectoryGraphQl/etc/schema.graphqls b/app/code/Magento/DirectoryGraphQl/etc/schema.graphqls index f2bc576f95e8e..59c6a35e9a1ac 100644 --- a/app/code/Magento/DirectoryGraphQl/etc/schema.graphqls +++ b/app/code/Magento/DirectoryGraphQl/etc/schema.graphqls @@ -10,8 +10,10 @@ type Query { type Currency { base_currency_code: String base_currency_symbol: String + default_display_currecy_code: String @deprecated(reason: "Symbol was missed. Use `default_display_currency_code`.") default_display_currency_code: String - default_display_currency_symbol: String + default_display_currecy_symbol: String @deprecated(reason: "Symbol was missed. Use `default_display_currency_symbol`.") + default_display_currency_symbol available_currency_codes: [String] exchange_rates: [ExchangeRate] } From 6ebdde1f138cb5316b83dd437a5db329289ee8cb Mon Sep 17 00:00:00 2001 From: Ievgenii Gryshkun Date: Wed, 13 Mar 2019 13:21:47 +0200 Subject: [PATCH 03/13] Currency misspelled in graphql attributes --- app/code/Magento/DirectoryGraphQl/etc/schema.graphqls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/DirectoryGraphQl/etc/schema.graphqls b/app/code/Magento/DirectoryGraphQl/etc/schema.graphqls index 59c6a35e9a1ac..8da1920f9a444 100644 --- a/app/code/Magento/DirectoryGraphQl/etc/schema.graphqls +++ b/app/code/Magento/DirectoryGraphQl/etc/schema.graphqls @@ -13,7 +13,7 @@ type Currency { default_display_currecy_code: String @deprecated(reason: "Symbol was missed. Use `default_display_currency_code`.") default_display_currency_code: String default_display_currecy_symbol: String @deprecated(reason: "Symbol was missed. Use `default_display_currency_symbol`.") - default_display_currency_symbol + default_display_currency_symbol: String available_currency_codes: [String] exchange_rates: [ExchangeRate] } From 96ca3d488bb010959414e391160364ad2264e22b Mon Sep 17 00:00:00 2001 From: Ievgenii Gryshkun Date: Sat, 16 Mar 2019 08:31:53 +0200 Subject: [PATCH 04/13] While adding the product to Cart when the requested Qty is zero or less then zero, one was unexpectedly added --- .../Model/Cart/AddSimpleProductToCart.php | 5 +++++ .../GraphQl/Quote/AddSimpleProductToCartTest.php | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php index 1b32866ed883c..6868ce3f7f1ff 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php @@ -67,6 +67,11 @@ public function execute(Quote $cart, array $cartItemData): void { $sku = $this->extractSku($cartItemData); $qty = $this->extractQty($cartItemData); + if ($qty <= 0) { + throw new GraphQlInputException( + __('Please enter a number greater than 0 in this field.') + ); + } $customizableOptions = $this->extractCustomizableOptions($cartItemData); try { diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddSimpleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddSimpleProductToCartTest.php index 1e92a2e497bed..d9ab8db62a195 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddSimpleProductToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddSimpleProductToCartTest.php @@ -59,6 +59,22 @@ public function testAddSimpleProductToCart() self::assertEquals($sku, $response['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']); } + /** + * @magentoApiDataFixture Magento/Catalog/_files/products.php + * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php + * @expectedException \Exception + * @expectedExceptionMessage Please enter a number greater than 0 in this field. + */ + public function testAddSimpleProductToCartWithNegativeQty() + { + $sku = 'simple'; + $qty = -2; + $maskedQuoteId = $this->getMaskedQuoteId(); + + $query = $this->getAddSimpleProductQuery($maskedQuoteId, $sku, $qty); + $this->graphQlQuery($query); + } + /** * @return string */ From b5803c581bf0debfc7e7b45be41cf3e869a4fc20 Mon Sep 17 00:00:00 2001 From: Harniuk Bohdan Date: Sat, 16 Mar 2019 16:44:06 +0200 Subject: [PATCH 05/13] magento/graphql-ce#482: [Test Coverage] 'SetBillingAddressOnCart' functionality --- .../Customer/SetBillingAddressOnCartTest.php | 50 +++++++++++++++++++ .../Guest/SetBillingAddressOnCartTest.php | 49 ++++++++++++++++++ 2 files changed, 99 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 67a086311d71a..02cd428767ccc 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 @@ -423,6 +423,39 @@ public function testSetBillingAddressOnNonExistentCart() $this->graphQlQuery($query, [], '', $this->getHeaderMap()); } + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @dataProvider dataProviderSetWithoutRequiredParameters + * @param string $input + * @param string $message + * @throws \Exception + */ + public function testSetBillingAddressWithoutRequiredParameters(string $input, string $message) + { + $maskedQuoteId = $this->assignQuoteToCustomer(); + $input = str_replace('cart_id_value', $maskedQuoteId, $input); + + $query = <<expectExceptionMessage($message); + $this->graphQlQuery($query); + } + /** * Verify the all the whitelisted fields for a New Address Object * @@ -506,4 +539,21 @@ private function assignQuoteToCustomer( $this->quoteResource->save($quote); return $this->quoteIdToMaskedId->execute((int)$quote->getId()); } + + /** + * @return array + */ + public function dataProviderSetWithoutRequiredParameters() + { + return [ + 'missed_billing_address' => [ + 'cart_id: "cart_id_value"', + 'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput! was not provided.', + ], + 'missed_cart_id' => [ + 'billing_address: {}', + 'Required parameter "cart_id" is missing' + ] + ]; + } } 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 27de0d12e413d..de07b80b39592 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 @@ -263,6 +263,38 @@ public function testSetBillingAddressOnNonExistentCart() $this->graphQlQuery($query); } + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php + * @dataProvider dataProviderSetWithoutRequiredParameters + * @param string $input + * @param string $message + * @throws \Exception + */ + public function testSetBillingAddressWithoutRequiredParameters(string $input, string $message) + { + $maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_order_with_simple_product_without_address'); + $input = str_replace('cart_id_value', $maskedQuoteId, $input); + + $query = <<expectExceptionMessage($message); + $this->graphQlQuery($query); + } + /** * Verify the all the whitelisted fields for a New Address Object * @@ -297,4 +329,21 @@ private function getMaskedQuoteIdByReversedQuoteId(string $reversedQuoteId): str return $this->quoteIdToMaskedId->execute((int)$quote->getId()); } + + /** + * @return array + */ + public function dataProviderSetWithoutRequiredParameters() + { + return [ + 'missed_billing_address' => [ + 'cart_id: "cart_id_value"', + 'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput! was not provided.', + ], + 'missed_cart_id' => [ + 'billing_address: {}', + 'Required parameter "cart_id" is missing' + ] + ]; + } } From 6f8d99c750e7aeab547a1d6f34e2d9f7df0be505 Mon Sep 17 00:00:00 2001 From: Alex Taranovsky Date: Wed, 20 Mar 2019 18:04:53 +0200 Subject: [PATCH 06/13] 281 - [Shipping methods] Support of UPS shipping method 1. Test coverage for UPS "Ground" method --- .../Ups/SetUpsShippingMethodsOnCartTest.php | 147 ++++++++++++++++++ .../Ups/_files/enable_ups_shipping_method.php | 20 +++ .../enable_ups_shipping_method_rollback.php | 16 ++ 3 files changed, 183 insertions(+) create mode 100644 dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Ups/_files/enable_ups_shipping_method.php create mode 100644 dev/tests/integration/testsuite/Magento/Ups/_files/enable_ups_shipping_method_rollback.php diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php new file mode 100644 index 0000000000000..ed2e73946b528 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php @@ -0,0 +1,147 @@ +quoteResource = $objectManager->get(QuoteResource::class); + $this->quoteFactory = $objectManager->get(QuoteFactory::class); + $this->quoteIdToMaskedId = $objectManager->get(QuoteIdToMaskedQuoteIdInterface::class); + $this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); + } + + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php + * @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php + */ + public function testSetUpsShippingMethod() + { + $quote = $this->quoteFactory->create(); + $this->quoteResource->load($quote, 'test_order_1', 'reserved_order_id'); + $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$quote->getId()); + $shippingAddressId = (int)$quote->getShippingAddress()->getId(); + + $query = $this->getAddUpsShippingMethodQuery( + $maskedQuoteId, + $shippingAddressId, + self::CARRIER_CODE, + self::CARRIER_METHOD_CODE_GROUND + ); + + $response = $this->sendRequestWithToken($query); + $addressesInformation = $response['setShippingMethodsOnCart']['cart']['shipping_addresses']; + $expectedResult = [ + 'carrier_code' => self::CARRIER_CODE, + 'method_code' => self::CARRIER_METHOD_CODE_GROUND, + 'label' => 'United Parcel Service - Ground', + ]; + self::assertEquals($addressesInformation[0]['selected_shipping_method'], $expectedResult); + } + + /** + * Generates query for setting the specified shipping method on cart + * + * @param int $shippingAddressId + * @param string $maskedQuoteId + * @param string $carrierCode + * @param string $methodCode + * @return string + */ + private function getAddUpsShippingMethodQuery( + string $maskedQuoteId, + int $shippingAddressId, + string $carrierCode, + string $methodCode + ): string { + return <<customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); + $headerMap = ['Authorization' => 'Bearer ' . $customerToken]; + + return $this->graphQlQuery($query, [], '', $headerMap); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Ups/_files/enable_ups_shipping_method.php b/dev/tests/integration/testsuite/Magento/Ups/_files/enable_ups_shipping_method.php new file mode 100644 index 0000000000000..5c6c60866fafb --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Ups/_files/enable_ups_shipping_method.php @@ -0,0 +1,20 @@ +get(WriterInterface::class); + +$configWriter->save('carriers/ups/active', 1); + +$scopeConfig = $objectManager->get(ScopeConfigInterface::class); +$scopeConfig->clean(); diff --git a/dev/tests/integration/testsuite/Magento/Ups/_files/enable_ups_shipping_method_rollback.php b/dev/tests/integration/testsuite/Magento/Ups/_files/enable_ups_shipping_method_rollback.php new file mode 100644 index 0000000000000..6d7894879f97b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Ups/_files/enable_ups_shipping_method_rollback.php @@ -0,0 +1,16 @@ +create(WriterInterface::class); + +$configWriter->delete('carriers/ups/active'); From 30a2a80802afe5df8c81e948f2c1db4e2ce969b9 Mon Sep 17 00:00:00 2001 From: Alex Taranovsky Date: Wed, 20 Mar 2019 18:58:51 +0200 Subject: [PATCH 07/13] magento/graphql-ce#281: [Shipping methods] Support of UPS shipping method --- .../Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php index ed2e73946b528..af85b616be696 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php @@ -15,7 +15,7 @@ use Magento\TestFramework\TestCase\GraphQlAbstract; /** - * Test for setting offline shipping methods on cart + * Test for setting "UPS" shipping method on cart */ class SetUpsShippingMethodsOnCartTest extends GraphQlAbstract { From ef3cc3634fcf4d03030e50e8627a23ccd718b60e Mon Sep 17 00:00:00 2001 From: Ievgenii Gryshkun Date: Thu, 21 Mar 2019 08:12:17 +0200 Subject: [PATCH 08/13] Missing key model in Wishlist value data --- .../Model/Resolver/WishlistResolver.php | 5 ++++ .../Magento/GraphQl/Wishlist/WishlistTest.php | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/app/code/Magento/WishlistGraphQl/Model/Resolver/WishlistResolver.php b/app/code/Magento/WishlistGraphQl/Model/Resolver/WishlistResolver.php index e3a788af2ea7e..792928ab61aaf 100644 --- a/app/code/Magento/WishlistGraphQl/Model/Resolver/WishlistResolver.php +++ b/app/code/Magento/WishlistGraphQl/Model/Resolver/WishlistResolver.php @@ -13,6 +13,7 @@ use Magento\Wishlist\Model\ResourceModel\Wishlist as WishlistResourceModel; use Magento\Wishlist\Model\Wishlist; use Magento\Wishlist\Model\WishlistFactory; +use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException; /** * Fetches the Wishlist data according to the GraphQL schema @@ -51,6 +52,10 @@ public function resolve( ) { $customerId = $context->getUserId(); + /* Guest checking */ + if (!$customerId && 0 === $customerId) { + throw new GraphQlAuthorizationException(__('The current user cannot perform operations on wishlist')); + } /** @var Wishlist $wishlist */ $wishlist = $this->wishlistFactory->create(); $this->wishlistResource->load($wishlist, $customerId, 'customer_id'); diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/WishlistTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/WishlistTest.php index d570fc09b7714..4aac5d9445934 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/WishlistTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/WishlistTest.php @@ -93,6 +93,36 @@ public function testGetCustomerWishlist(): void $this->assertEquals($wishlistItemProduct->getName(), $response['wishlist']['items'][0]['product']['name']); } + /** + * @expectedException \Exception + * @expectedExceptionMessage The current user cannot perform operations on wishlist + */ + public function testGetGuestWishlist() + { + $query = + <<graphQlQuery($query); + } + /** * @param string $email * @param string $password From e0248ea3ce6416c9fea185a958278dd7bda1a951 Mon Sep 17 00:00:00 2001 From: AlexandrKozyr Date: Thu, 21 Mar 2019 22:14:48 +0000 Subject: [PATCH 09/13] [+] added tests for SetPaymentMethodOnCart functionality --- .../Model/Resolver/SetPaymentMethodOnCart.php | 4 +- .../Customer/SetPaymentMethodOnCartTest.php | 48 +++++++++++++++++++ .../Guest/SetPaymentMethodOnCartTest.php | 47 ++++++++++++++++++ 3 files changed, 97 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/SetPaymentMethodOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/SetPaymentMethodOnCart.php index a93c8032c996a..d1dcb4a48a76b 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/SetPaymentMethodOnCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/SetPaymentMethodOnCart.php @@ -60,12 +60,12 @@ public function __construct( public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) { if (!isset($args['input']['cart_id']) || empty($args['input']['cart_id'])) { - throw new GraphQlInputException(__('Required parameter "cart_id" is missing')); + throw new GraphQlInputException(__('Required parameter "cart_id" is missing.')); } $maskedCartId = $args['input']['cart_id']; if (!isset($args['input']['payment_method']['code']) || empty($args['input']['payment_method']['code'])) { - throw new GraphQlInputException(__('Required parameter "payment_method" is missing')); + throw new GraphQlInputException(__('Required parameter "code" for "payment_method" is missing.')); } $paymentMethodCode = $args['input']['payment_method']['code']; 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 c7da2144adb9e..dc970c3ab5893 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 @@ -171,6 +171,54 @@ public function testPaymentMethodOnNonExistentCart() $this->graphQlQuery($query, [], '', $this->getHeaderMap()); } + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php + * @param string $input + * @param string $message + * @dataProvider dataProviderSetPaymentMethodWithoutRequiredParameters + */ + public function testSetPaymentMethodWithoutRequiredParameters(string $input, string $message) + { + $query = <<expectExceptionMessage($message); + $this->graphQlQuery($query, [], '', $this->getHeaderMap()); + } + /** + * @return array + */ + public function dataProviderSetPaymentMethodWithoutRequiredParameters(): array + { + return [ + 'missed_cart_id' => [ + 'payment_method: {code: "'.Checkmo::PAYMENT_METHOD_CHECKMO_CODE.'"}', + 'Required parameter "cart_id" is missing.' + ], + 'missed_payment_method' => [ + 'cart_id: "test"', + 'Required parameter "code" for "payment_method" is missing.' + ], + 'missed_payment_method_code' => [ + 'cart_id: "test",payment_method: {code: ""}', + 'Required parameter "code" for "payment_method" is missing.' + ], + ]; + } + /** * @magentoApiDataFixture Magento/Checkout/_files/quote_with_payment_saved.php */ 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 182bbaf618505..6b6bf04b837dd 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 @@ -126,6 +126,53 @@ public function testSetPaymentMethodToCustomerCart() $this->graphQlQuery($query); } + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php + * @param string $input + * @param string $message + * @dataProvider dataProviderSetPaymentMethodWithoutRequiredParameters + */ + public function testSetPaymentMethodWithoutRequiredParameters(string $input, string $message) + { + $query = <<expectExceptionMessage($message); + $this->graphQlQuery($query); + } + /** + * @return array + */ + public function dataProviderSetPaymentMethodWithoutRequiredParameters(): array + { + return [ + 'missed_cart_id' => [ + 'payment_method: {code: "'.Checkmo::PAYMENT_METHOD_CHECKMO_CODE.'"}', + 'Required parameter "cart_id" is missing.' + ], + 'missed_payment_method' => [ + 'cart_id: "test"', + 'Required parameter "code" for "payment_method" is missing.' + ], + 'missed_payment_method_code' => [ + 'cart_id: "test",payment_method: {code: ""}', + 'Required parameter "code" for "payment_method" is missing.' + ], + ]; + } + /** * @expectedException \Exception * @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id" From 73088cdba04c5783165c0f2a7c20bae78c370ec2 Mon Sep 17 00:00:00 2001 From: Valerii Naida Date: Mon, 25 Mar 2019 13:17:47 -0500 Subject: [PATCH 10/13] GraphQL-281: [Shipping methods] Support of UPS shipping method --- .../Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php index af85b616be696..463f2c4af101f 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php @@ -83,8 +83,8 @@ public function testSetUpsShippingMethod() $addressesInformation = $response['setShippingMethodsOnCart']['cart']['shipping_addresses']; $expectedResult = [ 'carrier_code' => self::CARRIER_CODE, - 'method_code' => self::CARRIER_METHOD_CODE_GROUND, - 'label' => 'United Parcel Service - Ground', + 'method_code' => self::CARRIER_METHOD_CODE_GROUND, + 'label' => 'United Parcel Service - Ground', ]; self::assertEquals($addressesInformation[0]['selected_shipping_method'], $expectedResult); } From 5aa062cb4801d4311ddcde2c59b63c2f4dc16e49 Mon Sep 17 00:00:00 2001 From: Valerii Naida Date: Mon, 25 Mar 2019 13:33:16 -0500 Subject: [PATCH 11/13] GraphQL-483: [Test Coverage] 'SetPaymentMethodOnCart' functionality --- .../GraphQl/Quote/Customer/SetPaymentMethodOnCartTest.php | 4 ++-- .../GraphQl/Quote/Guest/SetPaymentMethodOnCartTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 dc970c3ab5893..51c48f5041dd9 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 @@ -205,7 +205,7 @@ public function dataProviderSetPaymentMethodWithoutRequiredParameters(): array { return [ 'missed_cart_id' => [ - 'payment_method: {code: "'.Checkmo::PAYMENT_METHOD_CHECKMO_CODE.'"}', + 'payment_method: {code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '"}', 'Required parameter "cart_id" is missing.' ], 'missed_payment_method' => [ @@ -213,7 +213,7 @@ public function dataProviderSetPaymentMethodWithoutRequiredParameters(): array 'Required parameter "code" for "payment_method" is missing.' ], 'missed_payment_method_code' => [ - 'cart_id: "test",payment_method: {code: ""}', + 'cart_id: "test", payment_method: {code: ""}', 'Required parameter "code" for "payment_method" is missing.' ], ]; 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 6b6bf04b837dd..017b85ba17b93 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 @@ -159,7 +159,7 @@ public function dataProviderSetPaymentMethodWithoutRequiredParameters(): array { return [ 'missed_cart_id' => [ - 'payment_method: {code: "'.Checkmo::PAYMENT_METHOD_CHECKMO_CODE.'"}', + 'payment_method: {code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '"}', 'Required parameter "cart_id" is missing.' ], 'missed_payment_method' => [ @@ -167,7 +167,7 @@ public function dataProviderSetPaymentMethodWithoutRequiredParameters(): array 'Required parameter "code" for "payment_method" is missing.' ], 'missed_payment_method_code' => [ - 'cart_id: "test",payment_method: {code: ""}', + 'cart_id: "test", payment_method: {code: ""}', 'Required parameter "code" for "payment_method" is missing.' ], ]; From 18cafdc0aaee73fe6320e0ad8e736d563d40ca51 Mon Sep 17 00:00:00 2001 From: Valerii Naida Date: Mon, 25 Mar 2019 15:55:34 -0500 Subject: [PATCH 12/13] GraphQL-482: [Test Coverage] 'SetBillingAddressOnCart' functionality --- .../GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php | 3 ++- .../GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php | 3 ++- 2 files changed, 4 insertions(+), 2 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 02cd428767ccc..f79e6b8211b00 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 @@ -548,7 +548,8 @@ public function dataProviderSetWithoutRequiredParameters() return [ 'missed_billing_address' => [ 'cart_id: "cart_id_value"', - 'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput! was not provided.', + 'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput!' + . 'was not provided.', ], 'missed_cart_id' => [ 'billing_address: {}', 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 de07b80b39592..81969cf610f74 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 @@ -338,7 +338,8 @@ public function dataProviderSetWithoutRequiredParameters() return [ 'missed_billing_address' => [ 'cart_id: "cart_id_value"', - 'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput! was not provided.', + 'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput!' + . 'was not provided.', ], 'missed_cart_id' => [ 'billing_address: {}', From 594e5563d671eb34409b7da35e80f4d35bf7ced9 Mon Sep 17 00:00:00 2001 From: Valerii Naida Date: Mon, 25 Mar 2019 16:41:47 -0500 Subject: [PATCH 13/13] GraphQL-482: [Test Coverage] 'SetBillingAddressOnCart' functionality --- .../GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php | 2 +- .../Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php | 2 +- 2 files changed, 2 insertions(+), 2 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 f79e6b8211b00..55a32f7cdf653 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 @@ -549,7 +549,7 @@ public function dataProviderSetWithoutRequiredParameters() 'missed_billing_address' => [ 'cart_id: "cart_id_value"', 'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput!' - . 'was not provided.', + . ' was not provided.', ], 'missed_cart_id' => [ 'billing_address: {}', 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 81969cf610f74..a2f092b9e0e1d 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 @@ -339,7 +339,7 @@ public function dataProviderSetWithoutRequiredParameters() 'missed_billing_address' => [ 'cart_id: "cart_id_value"', 'Field SetBillingAddressOnCartInput.billing_address of required type BillingAddressInput!' - . 'was not provided.', + . ' was not provided.', ], 'missed_cart_id' => [ 'billing_address: {}',