Skip to content

Commit 2bd1c30

Browse files
committed
GraphQL-608: Remove “cart_address_id” from “ShippingMethodInput”
1 parent fa8fc34 commit 2bd1c30

File tree

9 files changed

+28
-315
lines changed

9 files changed

+28
-315
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/GetQuoteAddress.php

Lines changed: 0 additions & 83 deletions
This file was deleted.

app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingMethodsOnCart.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,17 @@
1616
*/
1717
class SetShippingMethodsOnCart implements SetShippingMethodsOnCartInterface
1818
{
19-
/**
20-
* @var GetQuoteAddress
21-
*/
22-
private $getQuoteAddress;
23-
2419
/**
2520
* @var AssignShippingMethodToCart
2621
*/
2722
private $assignShippingMethodToCart;
2823

2924
/**
30-
* @param GetQuoteAddress $getQuoteAddress
3125
* @param AssignShippingMethodToCart $assignShippingMethodToCart
3226
*/
3327
public function __construct(
34-
GetQuoteAddress $getQuoteAddress,
3528
AssignShippingMethodToCart $assignShippingMethodToCart
3629
) {
37-
$this->getQuoteAddress = $getQuoteAddress;
3830
$this->assignShippingMethodToCart = $assignShippingMethodToCart;
3931
}
4032

@@ -60,8 +52,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
6052
}
6153
$methodCode = $shippingMethodInput['method_code'];
6254

63-
$cartAddressId = $cart->getBillingAddress()->getId();
64-
$quoteAddress = $this->getQuoteAddress->execute($cart, $cartAddressId, $context->getUserId());
65-
$this->assignShippingMethodToCart->execute($cart, $quoteAddress, $carrierCode, $methodCode);
55+
$shippingAddress = $cart->getShippingAddress();
56+
$this->assignShippingMethodToCart->execute($cart, $shippingAddress, $carrierCode, $methodCode);
6657
}
6758
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/CheckoutEndToEndTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,9 @@ public function testCheckoutWorkflow()
9292
$this->addProductToCart($cartId, $qty, $sku);
9393

9494
$this->setBillingAddress($cartId);
95-
$shippingAddress = $this->setShippingAddress($cartId);
95+
$shippingMethod = $this->setShippingAddress($cartId);
9696

97-
$shippingMethod = current($shippingAddress['available_shipping_methods']);
98-
$paymentMethod = $this->setShippingMethod($cartId, $shippingAddress['address_id'], $shippingMethod);
97+
$paymentMethod = $this->setShippingMethod($cartId, $shippingMethod);
9998
$this->setPaymentMethod($cartId, $paymentMethod);
10099

101100
$orderId = $this->placeOrder($cartId);
@@ -340,24 +339,22 @@ private function setShippingAddress(string $cartId): array
340339
self::assertArrayHasKey('amount', $availableShippingMethod);
341340
self::assertNotEmpty($availableShippingMethod['amount']);
342341

343-
return $shippingAddress;
342+
return $availableShippingMethod;
344343
}
345344

346345
/**
347346
* @param string $cartId
348-
* @param int $addressId
349347
* @param array $method
350348
* @return array
351349
*/
352-
private function setShippingMethod(string $cartId, int $addressId, array $method): array
350+
private function setShippingMethod(string $cartId, array $method): array
353351
{
354352
$query = <<<QUERY
355353
mutation {
356354
setShippingMethodsOnCart(input: {
357355
cart_id: "{$cartId}",
358356
shipping_methods: [
359357
{
360-
cart_address_id: {$addressId}
361358
carrier_code: "{$method['carrier_code']}"
362359
method_code: "{$method['method_code']}"
363360
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetOfflineShippingMethodsOnCartTest.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace Magento\GraphQl\Quote\Customer;
99

1010
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
11-
use Magento\GraphQl\Quote\GetQuoteShippingAddressIdByReservedQuoteId;
1211
use Magento\Integration\Api\CustomerTokenServiceInterface;
1312
use Magento\TestFramework\Helper\Bootstrap;
1413
use Magento\TestFramework\TestCase\GraphQlAbstract;
@@ -23,11 +22,6 @@ class SetOfflineShippingMethodsOnCartTest extends GraphQlAbstract
2322
*/
2423
private $getMaskedQuoteIdByReservedOrderId;
2524

26-
/**
27-
* @var GetQuoteShippingAddressIdByReservedQuoteId
28-
*/
29-
private $getQuoteShippingAddressIdByReservedQuoteId;
30-
3125
/**
3226
* @var CustomerTokenServiceInterface
3327
*/
@@ -40,9 +34,6 @@ protected function setUp()
4034
{
4135
$objectManager = Bootstrap::getObjectManager();
4236
$this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
43-
$this->getQuoteShippingAddressIdByReservedQuoteId = $objectManager->get(
44-
GetQuoteShippingAddressIdByReservedQuoteId::class
45-
);
4637
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
4738
}
4839

@@ -64,13 +55,11 @@ protected function setUp()
6455
public function testSetOfflineShippingMethod(string $carrierCode, string $methodCode, float $amount, string $label)
6556
{
6657
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
67-
$quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote');
6858

6959
$query = $this->getQuery(
7060
$maskedQuoteId,
7161
$methodCode,
72-
$carrierCode,
73-
$quoteAddressId
62+
$carrierCode
7463
);
7564
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
7665

@@ -111,22 +100,19 @@ public function offlineShippingMethodDataProvider(): array
111100
* @param string $maskedQuoteId
112101
* @param string $shippingMethodCode
113102
* @param string $shippingCarrierCode
114-
* @param int $shippingAddressId
115103
* @return string
116104
*/
117105
private function getQuery(
118106
string $maskedQuoteId,
119107
string $shippingMethodCode,
120-
string $shippingCarrierCode,
121-
int $shippingAddressId
108+
string $shippingCarrierCode
122109
): string {
123110
return <<<QUERY
124111
mutation {
125112
setShippingMethodsOnCart(input:
126113
{
127114
cart_id: "$maskedQuoteId",
128115
shipping_methods: [{
129-
cart_address_id: $shippingAddressId
130116
carrier_code: "$shippingCarrierCode"
131117
method_code: "$shippingMethodCode"
132118
}]

0 commit comments

Comments
 (0)