Skip to content

Commit 10a2202

Browse files
committed
428 - Test coverage: GetAvailableShippingMethodsTest
Fix for PHP Fatal error: Uncaught Exception: Exception occurred when running the "\/home\/travis\/build\/magento\/graphql-ce\/dev\/tests\/integration\/testsuite\/Magento\/Sales\/_files\/guest_quote_with_addresses.php" fixture: URL key for specified store already exists. in /home/travis/build/magento/graphql-ce/dev/tests/api-functional/framework/Magento/TestFramework/Annotation/ApiDataFixture.php:114
1 parent 36a5981 commit 10a2202

File tree

2 files changed

+38
-36
lines changed

2 files changed

+38
-36
lines changed

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

+19-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
declare(strict_types=1);
6+
declare(strict_types = 1);
77

88
namespace Magento\GraphQl\Quote\Customer;
99

@@ -44,11 +44,11 @@ class GetAvailableShippingMethodsTest extends GraphQlAbstract
4444
*/
4545
protected function setUp()
4646
{
47-
$objectManager = Bootstrap::getObjectManager();
48-
$this->quoteFactory = $objectManager->get(QuoteFactory::class);
49-
$this->quoteResource = $objectManager->create(QuoteResource::class);
47+
$objectManager = Bootstrap::getObjectManager();
48+
$this->quoteFactory = $objectManager->get(QuoteFactory::class);
49+
$this->quoteResource = $objectManager->create(QuoteResource::class);
5050
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
51-
$this->quoteIdToMaskedId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class);
51+
$this->quoteIdToMaskedId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class);
5252
}
5353

5454
/**
@@ -59,7 +59,7 @@ protected function setUp()
5959
public function testGetAvailableShippingMethods()
6060
{
6161
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_1');
62-
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId), [], '', $this->getHeaderMap());
62+
$response = $this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId), [], '', $this->getHeaderMap());
6363

6464
self::assertArrayHasKey('cart', $response);
6565
self::assertArrayHasKey('shipping_addresses', $response['cart']);
@@ -68,13 +68,13 @@ public function testGetAvailableShippingMethods()
6868
self::assertCount(1, $response['cart']['shipping_addresses'][0]['available_shipping_methods']);
6969

7070
$expectedAddressData = [
71-
'amount' => 10,
72-
'base_amount' => 10,
73-
'carrier_code' => 'flatrate',
74-
'carrier_title' => 'Flat Rate',
75-
'error_message' => '',
76-
'method_code' => 'flatrate',
77-
'method_title' => 'Fixed',
71+
'amount' => 10,
72+
'base_amount' => 10,
73+
'carrier_code' => 'flatrate',
74+
'carrier_title' => 'Flat Rate',
75+
'error_message' => '',
76+
'method_code' => 'flatrate',
77+
'method_title' => 'Fixed',
7878
'price_incl_tax' => 10,
7979
'price_excl_tax' => 10,
8080
];
@@ -98,7 +98,7 @@ public function testGetAvailableShippingMethodsFromAnotherCustomerCart()
9898
"The current user cannot perform operations on cart \"$maskedQuoteId\""
9999
);
100100

101-
$this->graphQlQuery($this->getQuery($maskedQuoteId), [], '', $this->getHeaderMap('[email protected]'));
101+
$this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId), [], '', $this->getHeaderMap('[email protected]'));
102102
}
103103

104104
/**
@@ -110,7 +110,7 @@ public function testGetAvailableShippingMethodsFromAnotherCustomerCart()
110110
public function testGetAvailableShippingMethodsIfShippingsAreNotSet()
111111
{
112112
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_1');
113-
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId), [], '', $this->getHeaderMap());
113+
$response = $this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId), [], '', $this->getHeaderMap());
114114

115115
self::assertEquals(0, count($response['cart']['shipping_addresses'][0]['available_shipping_methods']));
116116
}
@@ -125,7 +125,7 @@ public function testGetAvailableShippingMethodsIfShippingsAreNotSet()
125125
public function testGetAvailableShippingMethodsOfNonExistentCart()
126126
{
127127
$maskedQuoteId = 'non_existent_masked_id';
128-
$query = $this->getQuery($maskedQuoteId);
128+
$query = $this->getAvailableShippingMethodsQuery($maskedQuoteId);
129129

130130
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
131131
}
@@ -134,9 +134,10 @@ public function testGetAvailableShippingMethodsOfNonExistentCart()
134134
* @param string $maskedQuoteId
135135
* @return string
136136
*/
137-
private function getQuery(
137+
private function getAvailableShippingMethodsQuery(
138138
string $maskedQuoteId
139-
): string {
139+
): string
140+
{
140141
return <<<QUERY
141142
query {
142143
cart (cart_id: "{$maskedQuoteId}") {

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php

+19-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
declare(strict_types=1);
6+
declare(strict_types = 1);
77

88
namespace Magento\GraphQl\Quote\Guest;
99

@@ -38,10 +38,10 @@ class GetAvailableShippingMethodsTest extends GraphQlAbstract
3838
*/
3939
protected function setUp()
4040
{
41-
$objectManager = Bootstrap::getObjectManager();
42-
$this->quoteFactory = $objectManager->get(QuoteFactory::class);
43-
$this->quoteResource = $objectManager->create(QuoteResource::class);
44-
$this->quoteIdToMaskedId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class);
41+
$objectManager = Bootstrap::getObjectManager();
42+
$this->quoteFactory = $objectManager->get(QuoteFactory::class);
43+
$this->quoteResource = $objectManager->create(QuoteResource::class);
44+
$this->quoteIdToMaskedId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class);
4545
}
4646

4747
/**
@@ -52,7 +52,7 @@ protected function setUp()
5252
public function testGetAvailableShippingMethodsFromGuestCart()
5353
{
5454
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('guest_quote');
55-
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId));
55+
$response = $this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId));
5656

5757
self::assertArrayHasKey('cart', $response);
5858
self::assertArrayHasKey('shipping_addresses', $response['cart']);
@@ -61,13 +61,13 @@ public function testGetAvailableShippingMethodsFromGuestCart()
6161
self::assertCount(1, $response['cart']['shipping_addresses'][0]['available_shipping_methods']);
6262

6363
$expectedAddressData = [
64-
'amount' => 5,
65-
'base_amount' => 5,
66-
'carrier_code' => 'flatrate',
67-
'carrier_title' => 'Flat Rate',
68-
'error_message' => '',
69-
'method_code' => 'flatrate',
70-
'method_title' => 'Fixed',
64+
'amount' => 5,
65+
'base_amount' => 5,
66+
'carrier_code' => 'flatrate',
67+
'carrier_title' => 'Flat Rate',
68+
'error_message' => '',
69+
'method_code' => 'flatrate',
70+
'method_title' => 'Fixed',
7171
'price_incl_tax' => 5,
7272
'price_excl_tax' => 5,
7373
];
@@ -90,7 +90,7 @@ public function testGetAvailableShippingMethodsFromAnotherCustomerCart()
9090
"The current user cannot perform operations on cart \"$maskedQuoteId\""
9191
);
9292

93-
$this->graphQlQuery($this->getQuery($maskedQuoteId));
93+
$this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId));
9494
}
9595

9696
/**
@@ -102,7 +102,7 @@ public function testGetAvailableShippingMethodsFromAnotherCustomerCart()
102102
public function testGetAvailableShippingMethodsIfShippingsAreNotSet()
103103
{
104104
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('guest_quote');
105-
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId));
105+
$response = $this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId));
106106

107107
self::assertEquals(0, count($response['cart']['shipping_addresses'][0]['available_shipping_methods']));
108108
}
@@ -117,16 +117,17 @@ public function testGetAvailableShippingMethodsOfNonExistentCart()
117117
{
118118
$maskedQuoteId = 'non_existent_masked_id';
119119

120-
$this->graphQlQuery($this->getQuery($maskedQuoteId));
120+
$this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId));
121121
}
122122

123123
/**
124124
* @param string $maskedQuoteId
125125
* @return string
126126
*/
127-
private function getQuery(
127+
private function getAvailableShippingMethodsQuery(
128128
string $maskedQuoteId
129-
): string {
129+
): string
130+
{
130131
return <<<QUERY
131132
query {
132133
cart (cart_id: "{$maskedQuoteId}") {

0 commit comments

Comments
 (0)