Skip to content

Commit

Permalink
ENGCOM-6055: graphQl-987: [Test coverage] Cover exceptions in Magento…
Browse files Browse the repository at this point in the history
…\QuoteGraphQl… #991
  • Loading branch information
lenaorobei authored Oct 10, 2019
2 parents 055bd1a + 8ee5309 commit e644f1f
Showing 1 changed file with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,70 @@ public function testSetPaymentOnCartWithSimpleProduct()
self::assertArrayHasKey('order_number', $response['placeOrder']['order']);
}

/**
* @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_billing_address.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/set_simple_product_out_of_stock.php
*
* @dataProvider dataProviderSetPaymentOnCartWithException
* @param string $input
* @param string $message
* @throws \Exception
*/
public function testSetPaymentOnCartWithException(string $input, string $message)
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
$input = str_replace('cart_id_value', $maskedQuoteId, $input);

$query = <<<QUERY
mutation {
setPaymentMethodAndPlaceOrder(
input: {
{$input}
}
) {
order {
order_number
}
}
}
QUERY;

$this->expectExceptionMessage($message);
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
}

/**
* @return array
*/
public function dataProviderSetPaymentOnCartWithException(): array
{
return [
'missed_cart_id' => [
'payment_method: {
code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '"
}',
'Required parameter "cart_id" is missing',
],
'missed_payment_method' => [
'cart_id: "cart_id_value"',
'Required parameter "code" for "payment_method" is missing.',
],
'place_order_with_out_of_stock_products' => [
'cart_id: "cart_id_value"
payment_method: {
code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '"
}',
'Unable to place order: Some of the products are out of stock.',
],
];
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
Expand Down

0 comments on commit e644f1f

Please sign in to comment.