Skip to content

Commit

Permalink
ENGCOM-5209: magento#682: [Test coverage] Missed parameters at 'setBi…
Browse files Browse the repository at this point in the history
…llingAddressMutation' magento#700
  • Loading branch information
lenaorobei authored Jun 10, 2019
2 parents 037f7d6 + 6ea7b69 commit f9eb63f
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,89 @@ public function testSetNewBillingAddressAndFromAddressBookAtSameTime()
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
}

/**
* @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
*/
public function testSetNewBillingAddressWithoutCustomerAddressIdAndAddress()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');

$query = <<<QUERY
mutation {
setBillingAddressOnCart(
input: {
cart_id: "$maskedQuoteId"
billing_address: {
use_for_shipping: true
}
}
) {
cart {
billing_address {
city
}
}
}
}
QUERY;

self::expectExceptionMessage(
'The billing address must contain either "customer_address_id" or "address".'
);
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
}

/**
* @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_multishipping_with_two_shipping_addresses.php
*/
public function testSetNewBillingAddressWithUseForShippingAndMultishipping()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');

$query = <<<QUERY
mutation {
setBillingAddressOnCart(
input: {
cart_id: "$maskedQuoteId"
billing_address: {
address: {
firstname: "test firstname"
lastname: "test lastname"
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
region: "test region"
postcode: "887766"
country_code: "US"
telephone: "88776655"
save_in_address_book: false
}
use_for_shipping: true
}
}
) {
cart {
billing_address {
city
}
}
}
}
QUERY;

self::expectExceptionMessage(
'Using the "use_for_shipping" option with multishipping is not possible.'
);
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
}

/**
* _security
* @magentoApiDataFixture Magento/Customer/_files/customer.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,87 @@ public function dataProviderSetWithoutRequiredParameters(): array
];
}

/**
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
*/
public function testSetNewBillingAddressWithoutCustomerAddressIdAndAddress()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');

$query = <<<QUERY
mutation {
setBillingAddressOnCart(
input: {
cart_id: "$maskedQuoteId"
billing_address: {
use_for_shipping: true
}
}
) {
cart {
billing_address {
city
}
}
}
}
QUERY;

self::expectExceptionMessage(
'The billing address must contain either "customer_address_id" or "address".'
);
$this->graphQlMutation($query);
}

/**
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @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_multishipping_with_two_shipping_addresses.php
*/
public function testSetNewBillingAddressWithUseForShippingAndMultishipping()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');

$query = <<<QUERY
mutation {
setBillingAddressOnCart(
input: {
cart_id: "$maskedQuoteId"
billing_address: {
address: {
firstname: "test firstname"
lastname: "test lastname"
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
region: "test region"
postcode: "887766"
country_code: "US"
telephone: "88776655"
save_in_address_book: false
}
use_for_shipping: true
}
}
) {
cart {
billing_address {
city
}
}
}
}
QUERY;

self::expectExceptionMessage(
'Using the "use_for_shipping" option with multishipping is not possible.'
);
$this->graphQlMutation($query);
}

/**
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Model\QuoteFactory;
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
use Magento\TestFramework\Helper\Bootstrap;

/** @var QuoteFactory $quoteFactory */
$quoteFactory = Bootstrap::getObjectManager()->get(QuoteFactory::class);
/** @var QuoteResource $quoteResource */
$quoteResource = Bootstrap::getObjectManager()->get(QuoteResource::class);

$quote = $quoteFactory->create();
$quoteResource->load($quote, 'test_quote', 'reserved_order_id');

// phpcs:disable
require __DIR__ . '/../../../Multishipping/Fixtures/shipping_address_list.php';
// phpcs:enable

/** @var CartRepositoryInterface $quoteRepository */
$quoteRepository = $objectManager->get(CartRepositoryInterface::class);
$quote->collectTotals();
$quoteRepository->save($quote);

0 comments on commit f9eb63f

Please sign in to comment.