Skip to content

Commit 70df953

Browse files
ENGCOM-4728: graphQl-580: set disabled payment method test coverage #584
- Merge Pull Request magento/graphql-ce#584 from magento/graphql-ce:graphQl-580-set-disabled-payment-method-on-cart-test-coverage - Merged commits: 1. 3f77282
2 parents aec044d + 3f77282 commit 70df953

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
namespace Magento\GraphQl\Quote\Customer;
99

10+
use Exception;
1011
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
1112
use Magento\Integration\Api\CustomerTokenServiceInterface;
1213
use Magento\OfflinePayments\Model\Cashondelivery;
1314
use Magento\OfflinePayments\Model\Checkmo;
15+
use Magento\OfflinePayments\Model\Purchaseorder;
1416
use Magento\TestFramework\Helper\Bootstrap;
1517
use Magento\TestFramework\TestCase\GraphQlAbstract;
1618

@@ -66,7 +68,7 @@ public function testSetPaymentOnCartWithSimpleProduct()
6668
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
6769
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
6870
*
69-
* @expectedException \Exception
71+
* @expectedException Exception
7072
* @expectedExceptionMessage The shipping address is missing. Set the address and try again.
7173
*/
7274
public function testSetPaymentOnCartWithSimpleProductAndWithoutAddress()
@@ -105,7 +107,7 @@ public function testSetPaymentOnCartWithVirtualProduct()
105107
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
106108
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
107109
*
108-
* @expectedException \Exception
110+
* @expectedException Exception
109111
* @expectedExceptionMessage The requested Payment Method is not available.
110112
*/
111113
public function testSetNonExistentPaymentMethod()
@@ -120,7 +122,7 @@ public function testSetNonExistentPaymentMethod()
120122
/**
121123
* @magentoApiDataFixture Magento/Customer/_files/customer.php
122124
*
123-
* @expectedException \Exception
125+
* @expectedException Exception
124126
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
125127
*/
126128
public function testSetPaymentOnNonExistentCart()
@@ -180,7 +182,7 @@ public function testSetPaymentMethodToAnotherCustomerCart()
180182
*
181183
* @param string $input
182184
* @param string $message
183-
* @throws \Exception
185+
* @throws Exception
184186
* @dataProvider dataProviderSetPaymentMethodWithoutRequiredParameters
185187
*/
186188
public function testSetPaymentMethodWithoutRequiredParameters(string $input, string $message)
@@ -204,6 +206,24 @@ public function testSetPaymentMethodWithoutRequiredParameters(string $input, str
204206
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
205207
}
206208

209+
/**
210+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
211+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
212+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
213+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
214+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
215+
* @expectedException Exception
216+
* @expectedExceptionMessage The requested Payment Method is not available.
217+
*/
218+
public function testSetDisabledPaymentOnCart()
219+
{
220+
$methodCode = Purchaseorder::PAYMENT_METHOD_PURCHASEORDER_CODE;
221+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
222+
223+
$query = $this->getQuery($maskedQuoteId, $methodCode);
224+
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
225+
}
226+
207227
/**
208228
* @return array
209229
*/

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

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

88
namespace Magento\GraphQl\Quote\Guest;
99

10+
use Exception;
1011
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
1112
use Magento\OfflinePayments\Model\Cashondelivery;
1213
use Magento\OfflinePayments\Model\Checkmo;
14+
use Magento\OfflinePayments\Model\Purchaseorder;
1315
use Magento\TestFramework\Helper\Bootstrap;
1416
use Magento\TestFramework\TestCase\GraphQlAbstract;
1517

@@ -57,7 +59,7 @@ public function testSetPaymentOnCartWithSimpleProduct()
5759
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
5860
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
5961
*
60-
* @expectedException \Exception
62+
* @expectedException Exception
6163
* @expectedExceptionMessage The shipping address is missing. Set the address and try again.
6264
*/
6365
public function testSetPaymentOnCartWithSimpleProductAndWithoutAddress()
@@ -94,7 +96,7 @@ public function testSetPaymentOnCartWithVirtualProduct()
9496
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
9597
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
9698
*
97-
* @expectedException \Exception
99+
* @expectedException Exception
98100
* @expectedExceptionMessage The requested Payment Method is not available.
99101
*/
100102
public function testSetNonExistentPaymentMethod()
@@ -107,7 +109,7 @@ public function testSetNonExistentPaymentMethod()
107109
}
108110

109111
/**
110-
* @expectedException \Exception
112+
* @expectedException Exception
111113
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
112114
*/
113115
public function testSetPaymentOnNonExistentCart()
@@ -149,7 +151,7 @@ public function testSetPaymentMethodToCustomerCart()
149151
* @param string $input
150152
* @param string $message
151153
* @dataProvider dataProviderSetPaymentMethodWithoutRequiredParameters
152-
* @throws \Exception
154+
* @throws Exception
153155
*/
154156
public function testSetPaymentMethodWithoutRequiredParameters(string $input, string $message)
155157
{
@@ -216,6 +218,23 @@ public function testReSetPayment()
216218
self::assertEquals($methodCode, $response['setPaymentMethodOnCart']['cart']['selected_payment_method']['code']);
217219
}
218220

221+
/**
222+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
223+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
224+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
225+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
226+
* @expectedException Exception
227+
* @expectedExceptionMessage The requested Payment Method is not available.
228+
*/
229+
public function testSetDisabledPaymentOnCart()
230+
{
231+
$methodCode = Purchaseorder::PAYMENT_METHOD_PURCHASEORDER_CODE;
232+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
233+
234+
$query = $this->getQuery($maskedQuoteId, $methodCode);
235+
$this->graphQlQuery($query);
236+
}
237+
219238
/**
220239
* @param string $maskedQuoteId
221240
* @param string $methodCode

0 commit comments

Comments
 (0)