Skip to content

Commit 5d8807a

Browse files
committed
GraphQL-424: Test coverage: Set OfflineShipping methods on Cart
1 parent 9c5ef5b commit 5d8807a

File tree

1 file changed

+2
-145
lines changed

1 file changed

+2
-145
lines changed

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

Lines changed: 2 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -51,40 +51,6 @@ protected function setUp()
5151
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
5252
}
5353

54-
/**
55-
* Test for general routine of setting a shipping method on shopping cart
56-
*
57-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
58-
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
59-
*/
60-
public function testSetShippingMethodOnCart()
61-
{
62-
$shippingCarrierCode = 'flatrate';
63-
$shippingMethodCode = 'flatrate';
64-
$this->quoteResource->load(
65-
$this->quote,
66-
'test_order_1',
67-
'reserved_order_id'
68-
);
69-
$shippingAddress = $this->quote->getShippingAddress();
70-
$shippingAddressId = $shippingAddress->getId();
71-
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
72-
73-
$query = $this->prepareMutationQuery(
74-
$maskedQuoteId,
75-
$shippingMethodCode,
76-
$shippingCarrierCode,
77-
$shippingAddressId
78-
);
79-
80-
$response = $this->sendRequestWithToken($query);
81-
82-
self::assertArrayHasKey('setShippingMethodsOnCart', $response);
83-
self::assertArrayHasKey('cart', $response['setShippingMethodsOnCart']);
84-
$addressesInformation = $response['setShippingMethodsOnCart']['cart']['shipping_addresses'];
85-
self::assertCount(1, $addressesInformation);
86-
}
87-
8854
/**
8955
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
9056
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
@@ -142,114 +108,6 @@ public function testSetUpsOnCart()
142108
);
143109
}
144110

145-
/**
146-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
147-
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
148-
*/
149-
public function testSetShippingMethodWithWrongCartId()
150-
{
151-
$shippingCarrierCode = 'flatrate';
152-
$shippingMethodCode = 'flatrate';
153-
$shippingAddressId = '1';
154-
$maskedQuoteId = 'invalid';
155-
156-
$query = $this->prepareMutationQuery(
157-
$maskedQuoteId,
158-
$shippingMethodCode,
159-
$shippingCarrierCode,
160-
$shippingAddressId
161-
);
162-
163-
self::expectExceptionMessage("Could not find a cart with ID \"$maskedQuoteId\"");
164-
$this->sendRequestWithToken($query);
165-
}
166-
167-
/**
168-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
169-
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
170-
*/
171-
public function testSetNonExistingShippingMethod()
172-
{
173-
$shippingCarrierCode = 'non';
174-
$shippingMethodCode = 'existing';
175-
$this->quoteResource->load(
176-
$this->quote,
177-
'test_order_1',
178-
'reserved_order_id'
179-
);
180-
$shippingAddress = $this->quote->getShippingAddress();
181-
$shippingAddressId = $shippingAddress->getId();
182-
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
183-
184-
$query = $this->prepareMutationQuery(
185-
$maskedQuoteId,
186-
$shippingMethodCode,
187-
$shippingCarrierCode,
188-
$shippingAddressId
189-
);
190-
191-
self::expectExceptionMessage("Carrier with such method not found: $shippingCarrierCode, $shippingMethodCode");
192-
$this->sendRequestWithToken($query);
193-
}
194-
195-
/**
196-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
197-
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
198-
*/
199-
public function testSetShippingMethodWithNonExistingAddress()
200-
{
201-
$shippingCarrierCode = 'flatrate';
202-
$shippingMethodCode = 'flatrate';
203-
$this->quoteResource->load(
204-
$this->quote,
205-
'test_order_1',
206-
'reserved_order_id'
207-
);
208-
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
209-
$shippingAddressId = '-20';
210-
211-
$query = $this->prepareMutationQuery(
212-
$maskedQuoteId,
213-
$shippingMethodCode,
214-
$shippingCarrierCode,
215-
$shippingAddressId
216-
);
217-
218-
self::expectExceptionMessage("Could not find a cart address with ID \"$shippingAddressId\"");
219-
$this->sendRequestWithToken($query);
220-
}
221-
222-
/**
223-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
224-
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
225-
*/
226-
public function testSetShippingMethodByGuestToCustomerCart()
227-
{
228-
$shippingCarrierCode = 'flatrate';
229-
$shippingMethodCode = 'flatrate';
230-
$this->quoteResource->load(
231-
$this->quote,
232-
'test_order_1',
233-
'reserved_order_id'
234-
);
235-
$shippingAddress = $this->quote->getShippingAddress();
236-
$shippingAddressId = $shippingAddress->getId();
237-
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
238-
239-
$query = $this->prepareMutationQuery(
240-
$maskedQuoteId,
241-
$shippingMethodCode,
242-
$shippingCarrierCode,
243-
$shippingAddressId
244-
);
245-
246-
self::expectExceptionMessage(
247-
"The current user cannot perform operations on cart \"$maskedQuoteId\""
248-
);
249-
250-
$this->graphQlQuery($query);
251-
}
252-
253111
/**
254112
* Send request for setting the requested shipping method and check the output
255113
*
@@ -275,7 +133,7 @@ private function setShippingMethodAndCheckResponse(
275133
$shippingAddressId = $shippingAddress->getId();
276134
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
277135

278-
$query = $this->prepareMutationQuery(
136+
$query = $this->getQuery(
279137
$maskedQuoteId,
280138
$shippingMethodCode,
281139
$shippingCarrierCode,
@@ -300,7 +158,7 @@ private function setShippingMethodAndCheckResponse(
300158
* @param string $shippingAddressId
301159
* @return string
302160
*/
303-
private function prepareMutationQuery(
161+
private function getQuery(
304162
string $maskedQuoteId,
305163
string $shippingMethodCode,
306164
string $shippingCarrierCode,
@@ -343,7 +201,6 @@ private function prepareMutationQuery(
343201
*/
344202
private function sendRequestWithToken(string $query): array
345203
{
346-
347204
$customerToken = $this->customerTokenService->createCustomerAccessToken('customer@example.com', 'password');
348205
$headerMap = ['Authorization' => 'Bearer ' . $customerToken];
349206

0 commit comments

Comments
 (0)