Skip to content

Commit

Permalink
ENGCOM-4728: graphQl-580: set disabled payment method test coverage #584
Browse files Browse the repository at this point in the history


 - 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
  • Loading branch information
magento-engcom-team committed Apr 10, 2019
2 parents aec044d + 3f77282 commit 70df953
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

namespace Magento\GraphQl\Quote\Customer;

use Exception;
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
use Magento\Integration\Api\CustomerTokenServiceInterface;
use Magento\OfflinePayments\Model\Cashondelivery;
use Magento\OfflinePayments\Model\Checkmo;
use Magento\OfflinePayments\Model\Purchaseorder;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\GraphQlAbstract;

Expand Down Expand Up @@ -66,7 +68,7 @@ public function testSetPaymentOnCartWithSimpleProduct()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
*
* @expectedException \Exception
* @expectedException Exception
* @expectedExceptionMessage The shipping address is missing. Set the address and try again.
*/
public function testSetPaymentOnCartWithSimpleProductAndWithoutAddress()
Expand Down Expand Up @@ -105,7 +107,7 @@ public function testSetPaymentOnCartWithVirtualProduct()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
*
* @expectedException \Exception
* @expectedException Exception
* @expectedExceptionMessage The requested Payment Method is not available.
*/
public function testSetNonExistentPaymentMethod()
Expand All @@ -120,7 +122,7 @@ public function testSetNonExistentPaymentMethod()
/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
*
* @expectedException \Exception
* @expectedException Exception
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
*/
public function testSetPaymentOnNonExistentCart()
Expand Down Expand Up @@ -180,7 +182,7 @@ public function testSetPaymentMethodToAnotherCustomerCart()
*
* @param string $input
* @param string $message
* @throws \Exception
* @throws Exception
* @dataProvider dataProviderSetPaymentMethodWithoutRequiredParameters
*/
public function testSetPaymentMethodWithoutRequiredParameters(string $input, string $message)
Expand All @@ -204,6 +206,24 @@ public function testSetPaymentMethodWithoutRequiredParameters(string $input, str
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
* @expectedException Exception
* @expectedExceptionMessage The requested Payment Method is not available.
*/
public function testSetDisabledPaymentOnCart()
{
$methodCode = Purchaseorder::PAYMENT_METHOD_PURCHASEORDER_CODE;
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');

$query = $this->getQuery($maskedQuoteId, $methodCode);
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
}

/**
* @return array
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

namespace Magento\GraphQl\Quote\Guest;

use Exception;
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
use Magento\OfflinePayments\Model\Cashondelivery;
use Magento\OfflinePayments\Model\Checkmo;
use Magento\OfflinePayments\Model\Purchaseorder;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\GraphQlAbstract;

Expand Down Expand Up @@ -57,7 +59,7 @@ public function testSetPaymentOnCartWithSimpleProduct()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
*
* @expectedException \Exception
* @expectedException Exception
* @expectedExceptionMessage The shipping address is missing. Set the address and try again.
*/
public function testSetPaymentOnCartWithSimpleProductAndWithoutAddress()
Expand Down Expand Up @@ -94,7 +96,7 @@ public function testSetPaymentOnCartWithVirtualProduct()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
*
* @expectedException \Exception
* @expectedException Exception
* @expectedExceptionMessage The requested Payment Method is not available.
*/
public function testSetNonExistentPaymentMethod()
Expand All @@ -107,7 +109,7 @@ public function testSetNonExistentPaymentMethod()
}

/**
* @expectedException \Exception
* @expectedException Exception
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
*/
public function testSetPaymentOnNonExistentCart()
Expand Down Expand Up @@ -149,7 +151,7 @@ public function testSetPaymentMethodToCustomerCart()
* @param string $input
* @param string $message
* @dataProvider dataProviderSetPaymentMethodWithoutRequiredParameters
* @throws \Exception
* @throws Exception
*/
public function testSetPaymentMethodWithoutRequiredParameters(string $input, string $message)
{
Expand Down Expand Up @@ -216,6 +218,23 @@ public function testReSetPayment()
self::assertEquals($methodCode, $response['setPaymentMethodOnCart']['cart']['selected_payment_method']['code']);
}

/**
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
* @expectedException Exception
* @expectedExceptionMessage The requested Payment Method is not available.
*/
public function testSetDisabledPaymentOnCart()
{
$methodCode = Purchaseorder::PAYMENT_METHOD_PURCHASEORDER_CODE;
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');

$query = $this->getQuery($maskedQuoteId, $methodCode);
$this->graphQlQuery($query);
}

/**
* @param string $maskedQuoteId
* @param string $methodCode
Expand Down

0 comments on commit 70df953

Please sign in to comment.