Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Commit

Permalink
ENGCOM-4728: graphQl-580: set disabled payment method test coverage #584
Browse files Browse the repository at this point in the history
naydav authored Apr 10, 2019
2 parents b1a1b89 + 70df953 commit 1791b43
Showing 2 changed files with 47 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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;

@@ -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()
@@ -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()
@@ -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()
@@ -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)
@@ -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
*/
Original file line number Diff line number Diff line change
@@ -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;

@@ -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()
@@ -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()
@@ -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()
@@ -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)
{
@@ -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

0 comments on commit 1791b43

Please sign in to comment.