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

graphQl-581: set shipping method on an empty cart test coverage #586

Merged
Show file tree
Hide file tree
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 @@ -7,6 +7,7 @@

namespace Magento\GraphQl\Quote\Customer;

use Exception;
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
use Magento\GraphQl\Quote\GetQuoteShippingAddressIdByReservedQuoteId;
use Magento\Integration\Api\CustomerTokenServiceInterface;
Expand Down Expand Up @@ -132,7 +133,7 @@ public function testReSetShippingMethod()
* @param string $input
* @param string $message
* @dataProvider dataProviderSetShippingMethodWithWrongParameters
* @throws \Exception
* @throws Exception
*/
public function testSetShippingMethodWithWrongParameters(string $input, string $message)
{
Expand Down Expand Up @@ -261,7 +262,7 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array
* @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
* @expectedException Exception
* @expectedExceptionMessage You cannot specify multiple shipping methods.
*/
public function testSetMultipleShippingMethods()
Expand Down Expand Up @@ -307,7 +308,7 @@ public function testSetMultipleShippingMethods()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
*
* @expectedException \Exception
* @expectedException Exception
*/
public function testSetShippingMethodToGuestCart()
{
Expand Down Expand Up @@ -336,7 +337,7 @@ public function testSetShippingMethodToGuestCart()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
*
* @expectedException \Exception
* @expectedException Exception
*/
public function testSetShippingMethodToAnotherCustomerCart()
{
Expand Down Expand Up @@ -422,6 +423,30 @@ private function getQuery(
QUERY;
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
*
* @expectedException Exception
* @expectedExceptionMessage The shipping method can't be set for an empty cart. Add an item to cart and try again.
*/
public function testSetShippingMethodOnAnEmptyCart()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
$carrierCode = 'flatrate';
$methodCode = 'flatrate';
$quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote');

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

/**
* @param string $username
* @param string $password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Magento\GraphQl\Quote\Guest;

use Exception;
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
use Magento\GraphQl\Quote\GetQuoteShippingAddressIdByReservedQuoteId;
use Magento\TestFramework\Helper\Bootstrap;
Expand Down Expand Up @@ -85,7 +86,7 @@ public function testSetShippingMethodOnCartWithSimpleProduct()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_virtual_product.php
*
* @expectedException \Exception
* @expectedException Exception
* @expectedExceptionMessage The shipping address is missing. Set the address and try again.
*/
public function testSetShippingMethodOnCartWithSimpleProductAndWithoutAddress()
Expand Down Expand Up @@ -151,7 +152,7 @@ public function testReSetShippingMethod()
* @param string $input
* @param string $message
* @dataProvider dataProviderSetShippingMethodWithWrongParameters
* @throws \Exception
* @throws Exception
*/
public function testSetShippingMethodWithWrongParameters(string $input, string $message)
{
Expand Down Expand Up @@ -279,7 +280,7 @@ public function dataProviderSetShippingMethodWithWrongParameters(): array
* @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
* @expectedException Exception
* @expectedExceptionMessage You cannot specify multiple shipping methods.
*/
public function testSetMultipleShippingMethods()
Expand Down Expand Up @@ -325,7 +326,7 @@ public function testSetMultipleShippingMethods()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
*
* @expectedException \Exception
* @expectedException Exception
*/
public function testSetShippingMethodToCustomerCart()
{
Expand Down Expand Up @@ -373,6 +374,30 @@ public function testSetShippingMethodIfGuestIsNotOwnerOfAddress()
$this->graphQlQuery($query);
}

/**
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/quote_with_address.php
*
* @expectedException Exception
* @expectedExceptionMessage The shipping method can't be set for an empty cart. Add an item to cart and try again.
*/
public function testSetShippingMethodOnAnEmptyCart()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
$carrierCode = 'flatrate';
$methodCode = 'flatrate';
$quoteAddressId = $this->getQuoteShippingAddressIdByReservedQuoteId->execute('test_quote');

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

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