-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
36a5981
commit 10a2202
Showing
2 changed files
with
38 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
declare(strict_types = 1); | ||
|
||
namespace Magento\GraphQl\Quote\Customer; | ||
|
||
|
@@ -44,11 +44,11 @@ class GetAvailableShippingMethodsTest extends GraphQlAbstract | |
*/ | ||
protected function setUp() | ||
{ | ||
$objectManager = Bootstrap::getObjectManager(); | ||
$this->quoteFactory = $objectManager->get(QuoteFactory::class); | ||
$this->quoteResource = $objectManager->create(QuoteResource::class); | ||
$objectManager = Bootstrap::getObjectManager(); | ||
$this->quoteFactory = $objectManager->get(QuoteFactory::class); | ||
$this->quoteResource = $objectManager->create(QuoteResource::class); | ||
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); | ||
$this->quoteIdToMaskedId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class); | ||
$this->quoteIdToMaskedId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class); | ||
} | ||
|
||
/** | ||
|
@@ -59,7 +59,7 @@ protected function setUp() | |
public function testGetAvailableShippingMethods() | ||
{ | ||
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_1'); | ||
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId), [], '', $this->getHeaderMap()); | ||
$response = $this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId), [], '', $this->getHeaderMap()); | ||
|
||
self::assertArrayHasKey('cart', $response); | ||
self::assertArrayHasKey('shipping_addresses', $response['cart']); | ||
|
@@ -68,13 +68,13 @@ public function testGetAvailableShippingMethods() | |
self::assertCount(1, $response['cart']['shipping_addresses'][0]['available_shipping_methods']); | ||
|
||
$expectedAddressData = [ | ||
'amount' => 10, | ||
'base_amount' => 10, | ||
'carrier_code' => 'flatrate', | ||
'carrier_title' => 'Flat Rate', | ||
'error_message' => '', | ||
'method_code' => 'flatrate', | ||
'method_title' => 'Fixed', | ||
'amount' => 10, | ||
'base_amount' => 10, | ||
'carrier_code' => 'flatrate', | ||
'carrier_title' => 'Flat Rate', | ||
'error_message' => '', | ||
'method_code' => 'flatrate', | ||
'method_title' => 'Fixed', | ||
'price_incl_tax' => 10, | ||
'price_excl_tax' => 10, | ||
]; | ||
|
@@ -98,7 +98,7 @@ public function testGetAvailableShippingMethodsFromAnotherCustomerCart() | |
"The current user cannot perform operations on cart \"$maskedQuoteId\"" | ||
); | ||
|
||
$this->graphQlQuery($this->getQuery($maskedQuoteId), [], '', $this->getHeaderMap('[email protected]')); | ||
$this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId), [], '', $this->getHeaderMap('[email protected]')); | ||
} | ||
|
||
/** | ||
|
@@ -110,7 +110,7 @@ public function testGetAvailableShippingMethodsFromAnotherCustomerCart() | |
public function testGetAvailableShippingMethodsIfShippingsAreNotSet() | ||
{ | ||
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_1'); | ||
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId), [], '', $this->getHeaderMap()); | ||
$response = $this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId), [], '', $this->getHeaderMap()); | ||
|
||
self::assertEquals(0, count($response['cart']['shipping_addresses'][0]['available_shipping_methods'])); | ||
} | ||
|
@@ -125,7 +125,7 @@ public function testGetAvailableShippingMethodsIfShippingsAreNotSet() | |
public function testGetAvailableShippingMethodsOfNonExistentCart() | ||
{ | ||
$maskedQuoteId = 'non_existent_masked_id'; | ||
$query = $this->getQuery($maskedQuoteId); | ||
$query = $this->getAvailableShippingMethodsQuery($maskedQuoteId); | ||
|
||
$this->graphQlQuery($query, [], '', $this->getHeaderMap()); | ||
} | ||
|
@@ -134,9 +134,10 @@ public function testGetAvailableShippingMethodsOfNonExistentCart() | |
* @param string $maskedQuoteId | ||
* @return string | ||
*/ | ||
private function getQuery( | ||
private function getAvailableShippingMethodsQuery( | ||
string $maskedQuoteId | ||
): string { | ||
): string | ||
{ | ||
return <<<QUERY | ||
query { | ||
cart (cart_id: "{$maskedQuoteId}") { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters