Skip to content

Commit b8006ee

Browse files
committed
GraphQL-419: Test coverage: GetAvailablePaymentMethodsTest for Customer
1 parent 1356caa commit b8006ee

File tree

6 files changed

+43
-27
lines changed

6 files changed

+43
-27
lines changed

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

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ protected function setUp()
5454
/**
5555
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php
5656
*/
57-
public function testGetPaymentMethodsFromCustomerCart()
57+
public function testGetCartWithPaymentMethods()
5858
{
5959
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_item_with_items');
60-
$query = $this->getCartAvailablePaymentMethodsQuery($maskedQuoteId);
61-
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
60+
$query = $this->getQuery($maskedQuoteId);
61+
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
6262

6363
self::assertArrayHasKey('cart', $response);
6464
self::assertEquals('checkmo', $response['cart']['available_payment_methods'][0]['code']);
@@ -70,14 +70,31 @@ public function testGetPaymentMethodsFromCustomerCart()
7070
);
7171
}
7272

73+
/**
74+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
75+
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_saved.php
76+
*/
77+
public function testGetPaymentMethodsFromGuestCart()
78+
{
79+
$guestQuoteMaskedId = $this->getMaskedQuoteIdByReservedOrderId(
80+
'test_order_with_virtual_product_without_address'
81+
);
82+
$query = $this->getQuery($guestQuoteMaskedId);
83+
84+
$this->expectExceptionMessage(
85+
"The current user cannot perform operations on cart \"$guestQuoteMaskedId\""
86+
);
87+
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
88+
}
89+
7390
/**
7491
* @magentoApiDataFixture Magento/Customer/_files/three_customers.php
7592
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php
7693
*/
7794
public function testGetPaymentMethodsFromAnotherCustomerCart()
7895
{
7996
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_item_with_items');
80-
$query = $this->getCartAvailablePaymentMethodsQuery($maskedQuoteId);
97+
$query = $this->getQuery($maskedQuoteId);
8198

8299
$this->expectExceptionMessage(
83100
"The current user cannot perform operations on cart \"$maskedQuoteId\""
@@ -92,8 +109,8 @@ public function testGetPaymentMethodsFromAnotherCustomerCart()
92109
public function testGetPaymentMethodsIfPaymentsAreNotSet()
93110
{
94111
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_item_with_items');
95-
$query = $this->getCartAvailablePaymentMethodsQuery($maskedQuoteId);
96-
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
112+
$query = $this->getQuery($maskedQuoteId);
113+
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
97114

98115
self::assertEquals(0, count($response['cart']['available_payment_methods']));
99116
}
@@ -106,7 +123,7 @@ public function testGetPaymentMethodsIfPaymentsAreNotSet()
106123
public function testGetPaymentMethodsOfNonExistentCart()
107124
{
108125
$maskedQuoteId = 'non_existent_masked_id';
109-
$query = $this->getCartAvailablePaymentMethodsQuery($maskedQuoteId);
126+
$query = $this->getQuery($maskedQuoteId);
110127

111128
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
112129
}
@@ -115,9 +132,10 @@ public function testGetPaymentMethodsOfNonExistentCart()
115132
* @param string $maskedQuoteId
116133
* @return string
117134
*/
118-
private function getCartAvailablePaymentMethodsQuery(
135+
private function getQuery(
119136
string $maskedQuoteId
120-
) : string {
137+
): string
138+
{
121139
return <<<QUERY
122140
{
123141
cart(cart_id: "$maskedQuoteId") {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function testGetCart()
7272
}
7373

7474
/**
75-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
7675
* @magentoApiDataFixture Magento/Customer/_files/customer.php
76+
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
7777
*/
7878
public function testGetGuestCart()
7979
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function testRemoveItemIfItemIsNotBelongToCart()
129129
}
130130

131131
/**
132-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
132+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
133133
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_saved.php
134134
*/
135135
public function testRemoveItemFromGuestCart()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function testUpdateItemIfItemIsNotBelongToCart()
156156
}
157157

158158
/**
159-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
159+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
160160
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_saved.php
161161
*/
162162
public function testUpdateItemInGuestCart()

dev/tests/integration/testsuite/Magento/Payment/_files/disable_all_active_payment_methods.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,17 @@
77

88
use Magento\Config\Model\Config;
99
use Magento\Framework\App\Config\ScopeConfigInterface;
10+
use Magento\Store\Model\Store;
1011
use Magento\TestFramework\Helper\Bootstrap;
1112

12-
$processConfigData = function (Config $config, array $data) {
13-
foreach ($data as $key => $value) {
14-
$config->setDataByPath($key, $value);
15-
$config->save();
16-
}
17-
};
18-
19-
$objectManager = Bootstrap::getObjectManager();
20-
$paymentMethodList = $objectManager->get(\Magento\Payment\Api\PaymentMethodListInterface::class);
21-
$rollbackConfigKey = 'test/payment/disabled_payment_methods';
22-
$configData = [];
13+
$objectManager = Bootstrap::getObjectManager();
14+
$paymentMethodList = $objectManager->get(\Magento\Payment\Api\PaymentMethodListInterface::class);
15+
$rollbackConfigKey = 'test/payment/disabled_payment_methods';
16+
$configData = [];
2317
$disabledPaymentMethods = [];
2418

2519
// Get all active Payment Methods
26-
foreach ($paymentMethodList->getActiveList(\Magento\Store\Model\Store::DEFAULT_STORE_ID) as $paymentMethod) {
20+
foreach ($paymentMethodList->getActiveList(Store::DEFAULT_STORE_ID) as $paymentMethod) {
2721
$configData['payment/' . $paymentMethod->getCode() . '/active'] = 0;
2822
$disabledPaymentMethods[] = $paymentMethod->getCode();
2923
}
@@ -34,4 +28,8 @@
3428
$defConfig = $objectManager->create(Config::class);
3529
$defConfig->setScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
3630

37-
$processConfigData($defConfig, $configData);
31+
foreach ($configData as $key => $value) {
32+
$defConfig->setDataByPath($key, $value);
33+
$defConfig->save();
34+
}
35+

dev/tests/integration/testsuite/Magento/Payment/_files/disable_all_active_payment_methods_rollback.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
use Magento\Framework\App\Config\Storage\WriterInterface;
1010
use Magento\TestFramework\Helper\Bootstrap;
1111

12-
$objectManager = Bootstrap::getObjectManager();
12+
$objectManager = Bootstrap::getObjectManager();
1313
$rollbackConfigKey = 'test/payment/disabled_payment_methods';
1414

15-
$configWriter = $objectManager->create(WriterInterface::class);
15+
$configWriter = $objectManager->create(WriterInterface::class);
1616
$rollbackConfigValue = $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)
1717
->getStore(\Magento\Store\Model\Store::DEFAULT_STORE_ID)
1818
->getConfig($rollbackConfigKey);

0 commit comments

Comments
 (0)