diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php b/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php index 840dedb4f274..4d832f603cd9 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php @@ -50,7 +50,6 @@ public function execute(QuoteAddress $address): array } $addressData = array_merge($addressData, [ - 'address_id' => $address->getId(), 'address_type' => $addressType, 'country' => [ 'code' => $address->getCountryId(), diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/GetQuoteAddress.php b/app/code/Magento/QuoteGraphQl/Model/Cart/GetQuoteAddress.php deleted file mode 100644 index 89124c594dd8..000000000000 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/GetQuoteAddress.php +++ /dev/null @@ -1,83 +0,0 @@ -quoteAddressFactory = $quoteAddressFactory; - $this->quoteAddressResource = $quoteAddressResource; - } - - /** - * Get quote address - * - * @param CartInterface $cart - * @param int $quoteAddressId - * @param int|null $customerId - * @return AddressInterface - * @throws GraphQlAuthorizationException - * @throws GraphQlNoSuchEntityException - */ - public function execute(CartInterface $cart, int $quoteAddressId, ?int $customerId): AddressInterface - { - $quoteAddress = $this->quoteAddressFactory->create(); - - $this->quoteAddressResource->load($quoteAddress, $quoteAddressId); - if (null === $quoteAddress->getId()) { - throw new GraphQlNoSuchEntityException( - __('Could not find a cart address with ID "%cart_address_id"', ['cart_address_id' => $quoteAddressId]) - ); - } - - // TODO: GetQuoteAddress::execute should depend only on AddressInterface contract - // https://github.com/magento/graphql-ce/issues/550 - if ($quoteAddress->getQuoteId() !== $cart->getId()) { - throw new GraphQlNoSuchEntityException( - __('Cart does not contain address with ID "%cart_address_id"', ['cart_address_id' => $quoteAddressId]) - ); - } - - if ((int)$quoteAddress->getCustomerId() !== (int)$customerId) { - throw new GraphQlAuthorizationException( - __( - 'The current user cannot use cart address with ID "%cart_address_id"', - ['cart_address_id' => $quoteAddressId] - ) - ); - } - return $quoteAddress; - } -} diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingMethodsOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingMethodsOnCart.php index 730cf1b0ffee..b2526bdc04e9 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingMethodsOnCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingMethodsOnCart.php @@ -16,25 +16,17 @@ */ class SetShippingMethodsOnCart implements SetShippingMethodsOnCartInterface { - /** - * @var GetQuoteAddress - */ - private $getQuoteAddress; - /** * @var AssignShippingMethodToCart */ private $assignShippingMethodToCart; /** - * @param GetQuoteAddress $getQuoteAddress * @param AssignShippingMethodToCart $assignShippingMethodToCart */ public function __construct( - GetQuoteAddress $getQuoteAddress, AssignShippingMethodToCart $assignShippingMethodToCart ) { - $this->getQuoteAddress = $getQuoteAddress; $this->assignShippingMethodToCart = $assignShippingMethodToCart; } @@ -50,11 +42,6 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s } $shippingMethodInput = current($shippingMethodsInput); - if (!isset($shippingMethodInput['cart_address_id']) || empty($shippingMethodInput['cart_address_id'])) { - throw new GraphQlInputException(__('Required parameter "cart_address_id" is missing.')); - } - $cartAddressId = $shippingMethodInput['cart_address_id']; - if (!isset($shippingMethodInput['carrier_code']) || empty($shippingMethodInput['carrier_code'])) { throw new GraphQlInputException(__('Required parameter "carrier_code" is missing.')); } @@ -65,7 +52,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s } $methodCode = $shippingMethodInput['method_code']; - $quoteAddress = $this->getQuoteAddress->execute($cart, $cartAddressId, $context->getUserId()); - $this->assignShippingMethodToCart->execute($cart, $quoteAddress, $carrierCode, $methodCode); + $shippingAddress = $cart->getShippingAddress(); + $this->assignShippingMethodToCart->execute($cart, $shippingAddress, $carrierCode, $methodCode); } } diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls index a9784e97c895..3b34b994eabe 100644 --- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls +++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls @@ -115,7 +115,6 @@ input SetShippingMethodsOnCartInput { } input ShippingMethodInput { - cart_address_id: Int! carrier_code: String! method_code: String! } @@ -188,7 +187,6 @@ type Cart { } type CartAddress { - address_id: Int firstname: String lastname: String company: String diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/CheckoutEndToEndTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/CheckoutEndToEndTest.php index 8592a986c5dc..a49b84e20a8a 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/CheckoutEndToEndTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/CheckoutEndToEndTest.php @@ -92,10 +92,9 @@ public function testCheckoutWorkflow() $this->addProductToCart($cartId, $qty, $sku); $this->setBillingAddress($cartId); - $shippingAddress = $this->setShippingAddress($cartId); + $shippingMethod = $this->setShippingAddress($cartId); - $shippingMethod = current($shippingAddress['available_shipping_methods']); - $paymentMethod = $this->setShippingMethod($cartId, $shippingAddress['address_id'], $shippingMethod); + $paymentMethod = $this->setShippingMethod($cartId, $shippingMethod); $this->setPaymentMethod($cartId, $paymentMethod); $orderId = $this->placeOrder($cartId); @@ -307,7 +306,6 @@ private function setShippingAddress(string $cartId): array ) { cart { shipping_addresses { - address_id available_shipping_methods { carrier_code method_code @@ -325,8 +323,6 @@ private function setShippingAddress(string $cartId): array self::assertCount(1, $response['setShippingAddressesOnCart']['cart']['shipping_addresses']); $shippingAddress = current($response['setShippingAddressesOnCart']['cart']['shipping_addresses']); - self::assertArrayHasKey('address_id', $shippingAddress); - self::assertNotEmpty($shippingAddress['address_id']); self::assertArrayHasKey('available_shipping_methods', $shippingAddress); self::assertCount(1, $shippingAddress['available_shipping_methods']); @@ -340,16 +336,15 @@ private function setShippingAddress(string $cartId): array self::assertArrayHasKey('amount', $availableShippingMethod); self::assertNotEmpty($availableShippingMethod['amount']); - return $shippingAddress; + return $availableShippingMethod; } /** * @param string $cartId - * @param int $addressId * @param array $method * @return array */ - private function setShippingMethod(string $cartId, int $addressId, array $method): array + private function setShippingMethod(string $cartId, array $method): array { $query = <<getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class); - $this->getQuoteShippingAddressIdByReservedQuoteId = $objectManager->get( - GetQuoteShippingAddressIdByReservedQuoteId::class - ); $this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); } @@ -64,13 +55,11 @@ protected function setUp() public function testSetOfflineShippingMethod(string $carrierCode, string $methodCode, float $amount, string $label) { $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = $this->getQuery( $maskedQuoteId, $methodCode, - $carrierCode, - $quoteAddressId + $carrierCode ); $response = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); @@ -111,14 +100,12 @@ public function offlineShippingMethodDataProvider(): array * @param string $maskedQuoteId * @param string $shippingMethodCode * @param string $shippingCarrierCode - * @param int $shippingAddressId * @return string */ private function getQuery( string $maskedQuoteId, string $shippingMethodCode, - string $shippingCarrierCode, - int $shippingAddressId + string $shippingCarrierCode ): string { return <<getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class); - $this->getQuoteShippingAddressIdByReservedQuoteId = $objectManager->get( - GetQuoteShippingAddressIdByReservedQuoteId::class - ); $this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); } @@ -59,13 +50,11 @@ public function testSetShippingMethodOnCartWithSimpleProduct() $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); $carrierCode = 'flatrate'; $methodCode = 'flatrate'; - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = $this->getQuery( $maskedQuoteId, $methodCode, - $carrierCode, - $quoteAddressId + $carrierCode ); $response = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); @@ -98,13 +87,11 @@ public function testReSetShippingMethod() $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); $carrierCode = 'freeshipping'; $methodCode = 'freeshipping'; - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = $this->getQuery( $maskedQuoteId, $methodCode, - $carrierCode, - $quoteAddressId + $carrierCode ); $response = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); @@ -138,8 +125,7 @@ public function testReSetShippingMethod() public function testSetShippingMethodWithWrongParameters(string $input, string $message) { $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); - $input = str_replace(['cart_id_value', 'cart_address_id_value'], [$maskedQuoteId, $quoteAddressId], $input); + $input = str_replace('cart_id_value', $maskedQuoteId, $input); $query = << [ 'shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "flatrate" method_code: "flatrate" }]', @@ -183,31 +168,14 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array 'cart_id: "cart_id_value" shipping_methods: []', 'Required parameter "shipping_methods" is missing' ], - 'missed_cart_address_id' => [ - 'cart_id: "cart_id_value", shipping_methods: [{ - carrier_code: "flatrate" - method_code: "flatrate" - }]', - 'Required parameter "cart_address_id" is missing.' - ], - 'non_existent_cart_address_id' => [ - 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: -1 - carrier_code: "flatrate" - method_code: "flatrate" - }]', - 'Could not find a cart address with ID "-1"' - ], 'missed_carrier_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value method_code: "flatrate" }]', 'Field ShippingMethodInput.carrier_code of required type String! was not provided.' ], 'empty_carrier_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "" method_code: "flatrate" }]', @@ -215,7 +183,6 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array ], 'non_existent_carrier_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "wrong-carrier-code" method_code: "flatrate" }]', @@ -223,14 +190,12 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array ], 'missed_method_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "flatrate" }]', 'Required parameter "method_code" is missing.' ], 'empty_method_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "flatrate" method_code: "" }]', @@ -238,7 +203,6 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array ], 'non_existent_method_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "flatrate" method_code: "wrong-carrier-code" }]', @@ -246,7 +210,6 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array ], 'non_existent_shopping_cart' => [ 'cart_id: "non_existent_masked_id", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "flatrate" method_code: "flatrate" }]', @@ -254,7 +217,6 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array ], 'disabled_shipping_method' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "freeshipping" method_code: "freeshipping" }]', @@ -276,7 +238,6 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array public function testSetMultipleShippingMethods() { $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = <<getMaskedQuoteIdByReservedOrderId->execute('test_quote'); $carrierCode = 'flatrate'; $methodCode = 'flatrate'; - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = $this->getQuery( $maskedQuoteId, $methodCode, - $carrierCode, - $quoteAddressId + $carrierCode ); $this->expectExceptionMessage( @@ -352,12 +309,10 @@ public function testSetShippingMethodToAnotherCustomerCart() $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); $carrierCode = 'flatrate'; $methodCode = 'flatrate'; - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = $this->getQuery( $maskedQuoteId, $methodCode, - $carrierCode, - $quoteAddressId + $carrierCode ); $this->expectExceptionMessage( @@ -366,46 +321,16 @@ public function testSetShippingMethodToAnotherCustomerCart() $this->graphQlMutation($query, [], '', $this->getHeaderMap('customer2@search.example.com')); } - /** - * _security - * @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_shipping_address.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/quote_with_address.php - */ - public function testSetShippingMethodIfCustomerIsNotOwnerOfAddress() - { - $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - $carrierCode = 'flatrate'; - $methodCode = 'flatrate'; - $anotherQuoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('guest_quote_with_address'); - $query = $this->getQuery( - $maskedQuoteId, - $methodCode, - $carrierCode, - $anotherQuoteAddressId - ); - - $this->expectExceptionMessage( - "Cart does not contain address with ID \"{$anotherQuoteAddressId}\"" - ); - $this->graphQlMutation($query, [], '', $this->getHeaderMap()); - } - /** * @param string $maskedQuoteId * @param string $shippingMethodCode * @param string $shippingCarrierCode - * @param int $shippingAddressId * @return string */ private function getQuery( string $maskedQuoteId, string $shippingMethodCode, - string $shippingCarrierCode, - int $shippingAddressId + string $shippingCarrierCode ): string { return <<getMaskedQuoteIdByReservedOrderId->execute('test_quote'); $carrierCode = 'flatrate'; $methodCode = 'flatrate'; - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = $this->getQuery( $maskedQuoteId, $methodCode, - $carrierCode, - $quoteAddressId + $carrierCode ); $this->graphQlMutation($query, [], '', $this->getHeaderMap()); } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CheckoutEndToEndTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CheckoutEndToEndTest.php index f5114b9253a4..7cd4e06a19e2 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CheckoutEndToEndTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CheckoutEndToEndTest.php @@ -77,10 +77,9 @@ public function testCheckoutWorkflow() $this->addProductToCart($cartId, $qty, $sku); $this->setBillingAddress($cartId); - $shippingAddress = $this->setShippingAddress($cartId); + $shippingMethod = $this->setShippingAddress($cartId); - $shippingMethod = current($shippingAddress['available_shipping_methods']); - $paymentMethod = $this->setShippingMethod($cartId, $shippingAddress['address_id'], $shippingMethod); + $paymentMethod = $this->setShippingMethod($cartId, $shippingMethod); $this->setPaymentMethod($cartId, $paymentMethod); $this->placeOrder($cartId); @@ -267,7 +266,6 @@ private function setShippingAddress(string $cartId): array ) { cart { shipping_addresses { - address_id available_shipping_methods { carrier_code method_code @@ -285,8 +283,6 @@ private function setShippingAddress(string $cartId): array self::assertCount(1, $response['setShippingAddressesOnCart']['cart']['shipping_addresses']); $shippingAddress = current($response['setShippingAddressesOnCart']['cart']['shipping_addresses']); - self::assertArrayHasKey('address_id', $shippingAddress); - self::assertNotEmpty($shippingAddress['address_id']); self::assertArrayHasKey('available_shipping_methods', $shippingAddress); self::assertCount(1, $shippingAddress['available_shipping_methods']); @@ -300,16 +296,15 @@ private function setShippingAddress(string $cartId): array self::assertArrayHasKey('amount', $availableShippingMethod); self::assertNotEmpty($availableShippingMethod['amount']); - return $shippingAddress; + return $availableShippingMethod; } /** * @param string $cartId - * @param int $addressId * @param array $method * @return array */ - private function setShippingMethod(string $cartId, int $addressId, array $method): array + private function setShippingMethod(string $cartId, array $method): array { $query = <<getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class); - $this->getQuoteShippingAddressIdByReservedQuoteId = $objectManager->get( - GetQuoteShippingAddressIdByReservedQuoteId::class - ); } /** @@ -56,13 +47,11 @@ protected function setUp() public function testSetOfflineShippingMethod(string $carrierCode, string $methodCode, float $amount, string $label) { $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = $this->getQuery( $maskedQuoteId, $methodCode, - $carrierCode, - $quoteAddressId + $carrierCode ); $response = $this->graphQlMutation($query); @@ -103,14 +92,12 @@ public function offlineShippingMethodDataProvider(): array * @param string $maskedQuoteId * @param string $shippingMethodCode * @param string $shippingCarrierCode - * @param int $shippingAddressId * @return string */ private function getQuery( string $maskedQuoteId, string $shippingMethodCode, - string $shippingCarrierCode, - int $shippingAddressId + string $shippingCarrierCode ): string { return <<getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class); - $this->getQuoteShippingAddressIdByReservedQuoteId = $objectManager->get( - GetQuoteShippingAddressIdByReservedQuoteId::class - ); } /** @@ -51,13 +42,11 @@ public function testSetShippingMethodOnCartWithSimpleProduct() $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); $carrierCode = 'flatrate'; $methodCode = 'flatrate'; - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = $this->getQuery( $maskedQuoteId, $methodCode, - $carrierCode, - $quoteAddressId + $carrierCode ); $response = $this->graphQlMutation($query); @@ -94,13 +83,11 @@ public function testSetShippingMethodOnCartWithSimpleProductAndWithoutAddress() $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); $carrierCode = 'flatrate'; $methodCode = 'flatrate'; - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = $this->getQuery( $maskedQuoteId, $methodCode, - $carrierCode, - $quoteAddressId + $carrierCode ); $this->graphQlMutation($query); } @@ -118,13 +105,11 @@ public function testReSetShippingMethod() $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); $carrierCode = 'freeshipping'; $methodCode = 'freeshipping'; - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = $this->getQuery( $maskedQuoteId, $methodCode, - $carrierCode, - $quoteAddressId + $carrierCode ); $response = $this->graphQlMutation($query); @@ -157,8 +142,7 @@ public function testReSetShippingMethod() public function testSetShippingMethodWithWrongParameters(string $input, string $message) { $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); - $input = str_replace(['cart_id_value', 'cart_address_id_value'], [$maskedQuoteId, $quoteAddressId], $input); + $input = str_replace('cart_id_value', $maskedQuoteId, $input); $query = << [ 'shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "flatrate" method_code: "flatrate" }]', @@ -202,31 +185,14 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array 'cart_id: "cart_id_value" shipping_methods: []', 'Required parameter "shipping_methods" is missing' ], - 'missed_cart_address_id' => [ - 'cart_id: "cart_id_value", shipping_methods: [{ - carrier_code: "flatrate" - method_code: "flatrate" - }]', - 'Required parameter "cart_address_id" is missing.' - ], - 'non_existent_cart_address_id' => [ - 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: -1 - carrier_code: "flatrate" - method_code: "flatrate" - }]', - 'Could not find a cart address with ID "-1"' - ], 'missed_carrier_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value method_code: "flatrate" }]', 'Field ShippingMethodInput.carrier_code of required type String! was not provided.' ], 'empty_carrier_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "" method_code: "flatrate" }]', @@ -234,7 +200,6 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array ], 'non_existent_carrier_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "wrong-carrier-code" method_code: "flatrate" }]', @@ -242,14 +207,12 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array ], 'missed_method_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "flatrate" }]', 'Required parameter "method_code" is missing.' ], 'empty_method_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "flatrate" method_code: "" }]', @@ -257,7 +220,6 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array ], 'non_existent_method_code' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "flatrate" method_code: "wrong-carrier-code" }]', @@ -265,7 +227,6 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array ], 'non_existent_shopping_cart' => [ 'cart_id: "non_existent_masked_id", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "flatrate" method_code: "flatrate" }]', @@ -273,7 +234,6 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array ], 'disabled_shipping_method' => [ 'cart_id: "cart_id_value", shipping_methods: [{ - cart_address_id: cart_address_id_value carrier_code: "freeshipping" method_code: "freeshipping" }]', @@ -294,7 +254,6 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array public function testSetMultipleShippingMethods() { $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = <<getMaskedQuoteIdByReservedOrderId->execute('test_quote'); $carrierCode = 'flatrate'; $methodCode = 'flatrate'; - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = $this->getQuery( $maskedQuoteId, $methodCode, - $carrierCode, - $quoteAddressId + $carrierCode ); $this->expectExceptionMessage( @@ -354,34 +309,7 @@ public function testSetShippingMethodToCustomerCart() ); $this->graphQlMutation($query); } - - /** - * _security - * @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 - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/quote_with_address.php - */ - public function testSetShippingMethodIfGuestIsNotOwnerOfAddress() - { - $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - $carrierCode = 'flatrate'; - $methodCode = 'flatrate'; - $anotherQuoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('guest_quote_with_address'); - $query = $this->getQuery( - $maskedQuoteId, - $methodCode, - $carrierCode, - $anotherQuoteAddressId - ); - - $this->expectExceptionMessage( - "Cart does not contain address with ID \"{$anotherQuoteAddressId}\"" - ); - $this->graphQlMutation($query); - } - + /** * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php @@ -395,13 +323,11 @@ public function testSetShippingMethodOnAnEmptyCart() $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); $carrierCode = 'flatrate'; $methodCode = 'flatrate'; - $quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote'); $query = $this->getQuery( $maskedQuoteId, $methodCode, - $carrierCode, - $quoteAddressId + $carrierCode ); $this->graphQlMutation($query); } @@ -410,14 +336,12 @@ public function testSetShippingMethodOnAnEmptyCart() * @param string $maskedQuoteId * @param string $shippingMethodCode * @param string $shippingCarrierCode - * @param int $shippingAddressId * @return string */ private function getQuery( string $maskedQuoteId, string $shippingMethodCode, - string $shippingCarrierCode, - int $shippingAddressId + string $shippingCarrierCode ): string { return <<customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); $this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class); - $this->getQuoteShippingAddressIdByReservedQuoteId = $objectManager->get( - GetQuoteShippingAddressIdByReservedQuoteId::class - ); } /** @@ -102,9 +93,8 @@ public function testSetUpsShippingMethod(string $methodCode, string $methodLabel { $quoteReservedId = 'test_quote'; $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($quoteReservedId); - $shippingAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute($quoteReservedId); - $query = $this->getQuery($maskedQuoteId, $shippingAddressId, self::CARRIER_CODE, $methodCode); + $query = $this->getQuery($maskedQuoteId, self::CARRIER_CODE, $methodCode); $response = $this->sendRequestWithToken($query); self::assertArrayHasKey('setShippingMethodsOnCart', $response); @@ -158,9 +148,8 @@ public function testSetUpsShippingMethodBasedOnCanadaAddress(string $methodCode, { $quoteReservedId = 'test_quote'; $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($quoteReservedId); - $shippingAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute($quoteReservedId); - $query = $this->getQuery($maskedQuoteId, $shippingAddressId, self::CARRIER_CODE, $methodCode); + $query = $this->getQuery($maskedQuoteId, self::CARRIER_CODE, $methodCode); $response = $this->sendRequestWithToken($query); self::assertArrayHasKey('setShippingMethodsOnCart', $response); @@ -201,7 +190,6 @@ public function dataProviderShippingMethodsBasedOnCanadaAddress(): array /** * Generates query for setting the specified shipping method on cart * - * @param int $shippingAddressId * @param string $maskedQuoteId * @param string $carrierCode * @param string $methodCode @@ -209,7 +197,6 @@ public function dataProviderShippingMethodsBasedOnCanadaAddress(): array */ private function getQuery( string $maskedQuoteId, - int $shippingAddressId, string $carrierCode, string $methodCode ): string { @@ -219,7 +206,6 @@ private function getQuery( cart_id: "$maskedQuoteId" shipping_methods: [ { - cart_address_id: $shippingAddressId carrier_code: "$carrierCode" method_code: "$methodCode" }