Skip to content

Commit

Permalink
ENGCOM-4727: graphQl-581: set shipping method on an empty cart test c…
Browse files Browse the repository at this point in the history
…overage #586

 - Merge Pull Request magento/graphql-ce#586 from magento/graphql-ce:graphQl-581-set-shipping-method-on-an-empty-cart-test-coverage
 - Merged commits:
   1. 8e40ce2
  • Loading branch information
magento-engcom-team committed Apr 10, 2019
2 parents aec044d + 8e40ce2 commit 3d10fcc
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 8 deletions.
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

0 comments on commit 3d10fcc

Please sign in to comment.