Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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