Skip to content

Commit

Permalink
GraphQL-420: Test coverage: GetAvailablePaymentMethodsTest for Guest
Browse files Browse the repository at this point in the history
  • Loading branch information
naydav committed Mar 13, 2019
1 parent 2bd07f7 commit e24a4c8
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ protected function setUp()
/**
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
*/
public function testGetPaymentMethodsFromGuestCart()
public function testGetCartWithPaymentMethods()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_with_simple_product_without_address');
$query = $this->getCartAvailablePaymentMethodsQuery($maskedQuoteId);
$response = $this->graphQlQuery($query);
$query = $this->getQuery($maskedQuoteId);
$response = $this->graphQlQuery($query);

self::assertArrayHasKey('cart', $response);

Expand All @@ -73,10 +73,10 @@ public function testGetPaymentMethodsFromGuestCart()
/**
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
*/
public function testGetPaymentMethodsFromAnotherCustomerCart()
public function testGetPaymentMethodsFromCustomerCart()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_1');
$query = $this->getCartAvailablePaymentMethodsQuery($maskedQuoteId);
$query = $this->getQuery($maskedQuoteId);

$this->expectExceptionMessage(
"The current user cannot perform operations on cart \"$maskedQuoteId\""
Expand All @@ -91,8 +91,8 @@ public function testGetPaymentMethodsFromAnotherCustomerCart()
public function testGetPaymentMethodsIfPaymentsAreNotSet()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_with_simple_product_without_address');
$query = $this->getCartAvailablePaymentMethodsQuery($maskedQuoteId);
$response = $this->graphQlQuery($query);
$query = $this->getQuery($maskedQuoteId);
$response = $this->graphQlQuery($query);

self::assertEquals(0, count($response['cart']['available_payment_methods']));
}
Expand All @@ -104,17 +104,17 @@ public function testGetPaymentMethodsIfPaymentsAreNotSet()
public function testGetPaymentMethodsOfNonExistentCart()
{
$maskedQuoteId = 'non_existent_masked_id';
$query = $this->getCartAvailablePaymentMethodsQuery($maskedQuoteId);
$query = $this->getQuery($maskedQuoteId);
$this->graphQlQuery($query);
}

/**
* @param string $maskedQuoteId
* @return string
*/
private function getCartAvailablePaymentMethodsQuery(
private function getQuery(
string $maskedQuoteId
) : string {
): string {
return <<<QUERY
{
cart(cart_id: "$maskedQuoteId") {
Expand Down

0 comments on commit e24a4c8

Please sign in to comment.