Skip to content

Commit 99134c0

Browse files
committed
GraphQL-428: Test coverage: GetAvailableShippingMethodsTest
1 parent c0b8e3d commit 99134c0

File tree

4 files changed

+32
-27
lines changed

4 files changed

+32
-27
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function setUp()
5454
/**
5555
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php
5656
*/
57-
public function testGetCartWithPaymentMethods()
57+
public function testGetAvailablePaymentMethods()
5858
{
5959
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_item_with_items');
6060
$query = $this->getQuery($maskedQuoteId);
@@ -74,7 +74,7 @@ public function testGetCartWithPaymentMethods()
7474
* @magentoApiDataFixture Magento/Customer/_files/customer.php
7575
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_saved.php
7676
*/
77-
public function testGetPaymentMethodsFromGuestCart()
77+
public function testGetAvailablePaymentMethodsFromGuestCart()
7878
{
7979
$guestQuoteMaskedId = $this->getMaskedQuoteIdByReservedOrderId(
8080
'test_order_with_virtual_product_without_address'
@@ -91,7 +91,7 @@ public function testGetPaymentMethodsFromGuestCart()
9191
* @magentoApiDataFixture Magento/Customer/_files/three_customers.php
9292
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php
9393
*/
94-
public function testGetPaymentMethodsFromAnotherCustomerCart()
94+
public function testGetAvailablePaymentMethodsFromAnotherCustomerCart()
9595
{
9696
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_item_with_items');
9797
$query = $this->getQuery($maskedQuoteId);
@@ -106,7 +106,7 @@ public function testGetPaymentMethodsFromAnotherCustomerCart()
106106
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php
107107
* @magentoApiDataFixture Magento/Payment/_files/disable_all_active_payment_methods.php
108108
*/
109-
public function testGetPaymentMethodsIfPaymentsAreNotSet()
109+
public function testGetAvailablePaymentMethodsIfAllPaymentsAreDisabled()
110110
{
111111
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_item_with_items');
112112
$query = $this->getQuery($maskedQuoteId);
@@ -120,7 +120,7 @@ public function testGetPaymentMethodsIfPaymentsAreNotSet()
120120
* @expectedException \Exception
121121
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
122122
*/
123-
public function testGetPaymentMethodsOfNonExistentCart()
123+
public function testGetAvailablePaymentMethodsOfNonExistentCart()
124124
{
125125
$maskedQuoteId = 'non_existent_masked_id';
126126
$query = $this->getQuery($maskedQuoteId);

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ protected function setUp()
4646
{
4747
$objectManager = Bootstrap::getObjectManager();
4848
$this->quoteFactory = $objectManager->get(QuoteFactory::class);
49-
$this->quoteResource = $objectManager->create(QuoteResource::class);
49+
$this->quoteResource = $objectManager->get(QuoteResource::class);
5050
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
51-
$this->quoteIdToMaskedId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class);
51+
$this->quoteIdToMaskedId = $objectManager->get(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->getAvailableShippingMethodsQuery($maskedQuoteId), [], '', $this->getHeaderMap());
62+
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId), [], '', $this->getHeaderMap());
6363

6464
self::assertArrayHasKey('cart', $response);
6565
self::assertArrayHasKey('shipping_addresses', $response['cart']);
@@ -98,7 +98,12 @@ public function testGetAvailableShippingMethodsFromAnotherCustomerCart()
9898
"The current user cannot perform operations on cart \"$maskedQuoteId\""
9999
);
100100

101-
$this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId), [], '', $this->getHeaderMap('customer2@search.example.com'));
101+
$this->graphQlQuery(
102+
$this->getQuery($maskedQuoteId),
103+
[],
104+
'',
105+
$this->getHeaderMap('customer2@search.example.com')
106+
);
102107
}
103108

104109
/**
@@ -107,10 +112,10 @@ public function testGetAvailableShippingMethodsFromAnotherCustomerCart()
107112
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
108113
* @magentoApiDataFixture Magento/OfflineShipping/_files/disable_offline_shipping_methods.php
109114
*/
110-
public function testGetAvailableShippingMethodsIfShippingsAreNotSet()
115+
public function testGetAvailableShippingMethodsIfAllShippingsAreDisabled()
111116
{
112117
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_1');
113-
$response = $this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId), [], '', $this->getHeaderMap());
118+
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId), [], '', $this->getHeaderMap());
114119

115120
self::assertEquals(0, count($response['cart']['shipping_addresses'][0]['available_shipping_methods']));
116121
}
@@ -125,7 +130,7 @@ public function testGetAvailableShippingMethodsIfShippingsAreNotSet()
125130
public function testGetAvailableShippingMethodsOfNonExistentCart()
126131
{
127132
$maskedQuoteId = 'non_existent_masked_id';
128-
$query = $this->getAvailableShippingMethodsQuery($maskedQuoteId);
133+
$query = $this->getQuery($maskedQuoteId);
129134

130135
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
131136
}
@@ -134,7 +139,7 @@ public function testGetAvailableShippingMethodsOfNonExistentCart()
134139
* @param string $maskedQuoteId
135140
* @return string
136141
*/
137-
private function getAvailableShippingMethodsQuery(
142+
private function getQuery(
138143
string $maskedQuoteId
139144
): string
140145
{

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function setUp()
4747
/**
4848
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
4949
*/
50-
public function testGetCartWithPaymentMethods()
50+
public function testGetAvailablePaymentMethods()
5151
{
5252
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_with_simple_product_without_address');
5353
$query = $this->getQuery($maskedQuoteId);
@@ -73,7 +73,7 @@ public function testGetCartWithPaymentMethods()
7373
/**
7474
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
7575
*/
76-
public function testGetPaymentMethodsFromCustomerCart()
76+
public function testGetAvailablePaymentMethodsFromCustomerCart()
7777
{
7878
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_1');
7979
$query = $this->getQuery($maskedQuoteId);
@@ -88,7 +88,7 @@ public function testGetPaymentMethodsFromCustomerCart()
8888
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
8989
* @magentoApiDataFixture Magento/Payment/_files/disable_all_active_payment_methods.php
9090
*/
91-
public function testGetPaymentMethodsIfPaymentsAreNotSet()
91+
public function testGetPaymentMethodsIfPaymentsAreDisabled()
9292
{
9393
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_with_simple_product_without_address');
9494
$query = $this->getQuery($maskedQuoteId);
@@ -101,7 +101,7 @@ public function testGetPaymentMethodsIfPaymentsAreNotSet()
101101
* @expectedException \Exception
102102
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
103103
*/
104-
public function testGetPaymentMethodsOfNonExistentCart()
104+
public function testGetAvailablePaymentMethodsOfNonExistentCart()
105105
{
106106
$maskedQuoteId = 'non_existent_masked_id';
107107
$query = $this->getQuery($maskedQuoteId);

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ protected function setUp()
4040
{
4141
$objectManager = Bootstrap::getObjectManager();
4242
$this->quoteFactory = $objectManager->get(QuoteFactory::class);
43-
$this->quoteResource = $objectManager->create(QuoteResource::class);
44-
$this->quoteIdToMaskedId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class);
43+
$this->quoteResource = $objectManager->get(QuoteResource::class);
44+
$this->quoteIdToMaskedId = $objectManager->get(QuoteIdToMaskedQuoteIdInterface::class);
4545
}
4646

4747
/**
4848
* Test case: get available shipping methods from current customer quote
4949
*
5050
* @magentoApiDataFixture Magento/Sales/_files/guest_quote_with_addresses.php
5151
*/
52-
public function testGetAvailableShippingMethodsFromGuestCart()
52+
public function testGetAvailableShippingMethods()
5353
{
5454
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('guest_quote');
55-
$response = $this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId));
55+
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId));
5656

5757
self::assertArrayHasKey('cart', $response);
5858
self::assertArrayHasKey('shipping_addresses', $response['cart']);
@@ -82,15 +82,15 @@ public function testGetAvailableShippingMethodsFromGuestCart()
8282
*
8383
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
8484
*/
85-
public function testGetAvailableShippingMethodsFromAnotherCustomerCart()
85+
public function testGetAvailableShippingMethodsFromCustomerCart()
8686
{
8787
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_1');
8888

8989
$this->expectExceptionMessage(
9090
"The current user cannot perform operations on cart \"$maskedQuoteId\""
9191
);
9292

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

9696
/**
@@ -99,10 +99,10 @@ public function testGetAvailableShippingMethodsFromAnotherCustomerCart()
9999
* @magentoApiDataFixture Magento/Sales/_files/guest_quote_with_addresses.php
100100
* @magentoApiDataFixture Magento/OfflineShipping/_files/disable_offline_shipping_methods.php
101101
*/
102-
public function testGetAvailableShippingMethodsIfShippingsAreNotSet()
102+
public function testGetAvailableShippingMethodsIfShippingsAreDisabled()
103103
{
104104
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('guest_quote');
105-
$response = $this->graphQlQuery($this->getAvailableShippingMethodsQuery($maskedQuoteId));
105+
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId));
106106

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

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

123123
/**
124124
* @param string $maskedQuoteId
125125
* @return string
126126
*/
127-
private function getAvailableShippingMethodsQuery(
127+
private function getQuery(
128128
string $maskedQuoteId
129129
): string
130130
{

0 commit comments

Comments
 (0)