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

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
  • Loading branch information
naydav authored Apr 10, 2019
2 parents 1791b43 + 3d10fcc commit 9ae2264
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 @@ -269,7 +270,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 @@ -315,7 +316,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 @@ -344,7 +345,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 @@ -430,6 +431,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 @@ -287,7 +288,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 @@ -333,7 +334,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 @@ -381,6 +382,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 9ae2264

Please sign in to comment.