Skip to content

Commit b946dd0

Browse files
committed
GraphQL-540: Replace deprecated Magento/Checkout/_files/quote_with_address_saved.php fixture in SetUpsShippingMethodsOnCartTest
1 parent 38b106f commit b946dd0

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Ups/SetUpsShippingMethodsOnCartTest.php

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,39 +55,44 @@ protected function setUp()
5555
}
5656

5757
/**
58-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
59-
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
60-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
58+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
59+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
6160
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
6261
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
63-
* @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php
62+
* @magentoApiDataFixture Magento/GraphQl/Ups/_files/enable_ups_shipping_method.php
6463
*
65-
* @param string $carrierMethodCode
66-
* @param string $carrierMethodLabel
64+
* @param string $methodCode
65+
* @param string $methodLabel
6766
* @dataProvider availableForCartShippingMethods
6867
*/
69-
public function testSetAvailableForCartUpsShippingMethod(string $carrierMethodCode, string $carrierMethodLabel)
68+
public function testSetAvailableUpsShippingMethodOnCart(string $methodCode, string $methodLabel)
7069
{
7170
$quoteReservedId = 'test_quote';
7271
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($quoteReservedId);
7372
$shippingAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute($quoteReservedId);
7473

75-
$query = $this->getQuery(
76-
$maskedQuoteId,
77-
$shippingAddressId,
78-
self::CARRIER_CODE,
79-
$carrierMethodCode
80-
);
74+
$query = $this->getQuery($maskedQuoteId, $shippingAddressId, self::CARRIER_CODE, $methodCode);
75+
$response = $this->graphQlQuery($query);
8176

82-
$response = $this->sendRequestWithToken($query);
77+
self::assertArrayHasKey('setShippingMethodsOnCart', $response);
78+
self::assertArrayHasKey('cart', $response['setShippingMethodsOnCart']);
79+
self::assertArrayHasKey('shipping_addresses', $response['setShippingMethodsOnCart']['cart']);
80+
self::assertCount(1, $response['setShippingMethodsOnCart']['cart']['shipping_addresses']);
8381

84-
$addressesInformation = $response['setShippingMethodsOnCart']['cart']['shipping_addresses'];
85-
$expectedResult = [
86-
'carrier_code' => self::CARRIER_CODE,
87-
'method_code' => $carrierMethodCode,
88-
'label' => self::CARRIER_LABEL . ' - ' . $carrierMethodLabel,
89-
];
90-
self::assertEquals($addressesInformation[0]['selected_shipping_method'], $expectedResult);
82+
$shippingAddress = current($response['setShippingMethodsOnCart']['cart']['shipping_addresses']);
83+
self::assertArrayHasKey('selected_shipping_method', $shippingAddress);
84+
85+
self::assertArrayHasKey('carrier_code', $shippingAddress['selected_shipping_method']);
86+
self::assertEquals(self::CARRIER_CODE, $shippingAddress['selected_shipping_method']['carrier_code']);
87+
88+
self::assertArrayHasKey('method_code', $shippingAddress['selected_shipping_method']);
89+
self::assertEquals($methodCode, $shippingAddress['selected_shipping_method']['method_code']);
90+
91+
self::assertArrayHasKey('label', $shippingAddress['selected_shipping_method']);
92+
self::assertEquals(
93+
self::CARRIER_LABEL . ' - ' . $methodLabel,
94+
$shippingAddress['selected_shipping_method']['label']
95+
);
9196
}
9297

9398
/**
@@ -96,7 +101,7 @@ public function testSetAvailableForCartUpsShippingMethod(string $carrierMethodCo
96101
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
97102
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
98103
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
99-
* @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php
104+
* @magentoApiDataFixture Magento/GraphQl/Ups/_files/enable_ups_shipping_method.php
100105
*
101106
* @param string $carrierMethodCode
102107
* @param string $carrierMethodLabel

dev/tests/integration/testsuite/Magento/Ups/_files/enable_ups_shipping_method.php renamed to dev/tests/integration/testsuite/Magento/GraphQl/Ups/_files/enable_ups_shipping_method.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
// TODO: Should be removed in scope of https://github.com/magento/graphql-ce/issues/167
67
declare(strict_types=1);
78

89
use Magento\Framework\App\Config\Storage\Writer;

dev/tests/integration/testsuite/Magento/Ups/_files/enable_ups_shipping_method_rollback.php renamed to dev/tests/integration/testsuite/Magento/GraphQl/Ups/_files/enable_ups_shipping_method_rollback.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
// TODO: Should be removed in scope of https://github.com/magento/graphql-ce/issues/167
67
declare(strict_types=1);
78

89
use Magento\Framework\App\Config\Storage\Writer;

0 commit comments

Comments
 (0)