Skip to content

Commit cf51a02

Browse files
committed
Added test case for multiple shipping methods for one address
1 parent 40f547b commit cf51a02

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

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

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,59 @@ public function testSetOfflineShippingMethod(string $carrier, string $method, fl
7171
);
7272
}
7373

74+
/**
75+
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
76+
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
77+
*/
78+
public function testSetShippingMethodTwiceInOneRequest()
79+
{
80+
$quote = $this->quoteFactory->create();
81+
$this->quoteResource->load(
82+
$quote,
83+
'test_order_1',
84+
'reserved_order_id'
85+
);
86+
$shippingAddress = $quote->getShippingAddress();
87+
$shippingAddressId = $shippingAddress->getId();
88+
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$quote->getId());
89+
90+
$query = <<<QUERY
91+
mutation {
92+
setShippingMethodsOnCart(input:
93+
{
94+
cart_id: "$maskedQuoteId",
95+
shipping_methods: [
96+
{
97+
cart_address_id: $shippingAddressId
98+
method_code: "flatrate"
99+
carrier_code: "flatrate"
100+
}
101+
{
102+
cart_address_id: $shippingAddressId
103+
method_code: "freeshipping"
104+
carrier_code: "freeshipping"
105+
}
106+
]
107+
}) {
108+
109+
cart {
110+
shipping_addresses {
111+
selected_shipping_method {
112+
carrier_code
113+
method_code
114+
label
115+
amount
116+
}
117+
}
118+
}
119+
}
120+
}
121+
QUERY;
122+
123+
self::expectExceptionMessage('You cannot specify multiple shipping methods.');
124+
$this->sendRequestWithToken($query);
125+
}
126+
74127
/**
75128
* Data provider for base offline shipping methods
76129
*
@@ -90,7 +143,7 @@ public function offlineShippingMethodDataProvider()
90143
*
91144
* @param string $shippingCarrierCode
92145
* @param string $shippingMethodCode
93-
* @param string $shippingAmount
146+
* @param float $shippingAmount
94147
* @param string $shippingLabel
95148
* @throws \Magento\Framework\Exception\AuthenticationException
96149
* @throws \Magento\Framework\Exception\NoSuchEntityException
@@ -166,7 +219,6 @@ private function getQuery(
166219
}
167220
}
168221
}
169-
170222
QUERY;
171223
}
172224

0 commit comments

Comments
 (0)