Skip to content

Commit

Permalink
graphQl-296: fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Boyko committed Feb 7, 2019
1 parent 957ca74 commit d0578be
Showing 1 changed file with 45 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

namespace Magento\GraphQl\Quote;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Integration\Api\CustomerTokenServiceInterface;
use Magento\Multishipping\Helper\Data;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
Expand Down Expand Up @@ -79,7 +81,7 @@ public function testSetNewGuestShippingAddressOnCart()
}
) {
cart {
addresses {
shipping_addresses {
firstname
lastname
company
Expand All @@ -96,8 +98,8 @@ public function testSetNewGuestShippingAddressOnCart()

self::assertArrayHasKey('cart', $response['setShippingAddressesOnCart']);
$cartResponse = $response['setShippingAddressesOnCart']['cart'];
self::assertArrayHasKey('addresses', $cartResponse);
$shippingAddressResponse = current($cartResponse['addresses']);
self::assertArrayHasKey('shipping_addresses', $cartResponse);
$shippingAddressResponse = current($cartResponse['shipping_addresses']);
$this->assertNewShippingAddressFields($shippingAddressResponse);
}

Expand Down Expand Up @@ -126,7 +128,7 @@ public function testSetSavedShippingAddressOnCartByGuest()
}
) {
cart {
addresses {
shipping_addresses {
firstname
lastname
company
Expand Down Expand Up @@ -171,7 +173,7 @@ public function testSetMultipleShippingAddressesOnCartByGuest()
}
) {
cart {
addresses {
shipping_addresses {
firstname
lastname
company
Expand All @@ -184,6 +186,18 @@ public function testSetMultipleShippingAddressesOnCartByGuest()
}
}
QUERY;
/** @var \Magento\Config\Model\ResourceModel\Config $config */
$config = ObjectManager::getInstance()->get(\Magento\Config\Model\ResourceModel\Config::class);
$config->saveConfig(
Data::XML_PATH_CHECKOUT_MULTIPLE_AVAILABLE,
null,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
0
);
/** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */
$config = ObjectManager::getInstance()->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
$config->reinit();

self::expectExceptionMessage('You cannot specify multiple shipping addresses.');
$this->graphQlQuery($query);
}
Expand Down Expand Up @@ -225,7 +239,7 @@ public function testSetSavedAndNewShippingAddressOnCartAtTheSameTime()
}
) {
cart {
addresses {
shipping_addresses {
firstname
lastname
company
Expand Down Expand Up @@ -267,7 +281,7 @@ public function testSetShippingAddressOnCartWithNoAddresses()
}
) {
cart {
addresses {
shipping_addresses {
firstname
lastname
company
Expand Down Expand Up @@ -332,7 +346,7 @@ public function testSetNewRegisteredCustomerShippingAddressOnCart()
}
) {
cart {
addresses {
shipping_addresses {
firstname
lastname
company
Expand All @@ -349,8 +363,8 @@ public function testSetNewRegisteredCustomerShippingAddressOnCart()

self::assertArrayHasKey('cart', $response['setShippingAddressesOnCart']);
$cartResponse = $response['setShippingAddressesOnCart']['cart'];
self::assertArrayHasKey('addresses', $cartResponse);
$shippingAddressResponse = current($cartResponse['addresses']);
self::assertArrayHasKey('shipping_addresses', $cartResponse);
$shippingAddressResponse = current($cartResponse['shipping_addresses']);
$this->assertNewShippingAddressFields($shippingAddressResponse);
}

Expand Down Expand Up @@ -390,7 +404,7 @@ public function testSetSavedRegisteredCustomerShippingAddressOnCart()
}
) {
cart {
addresses {
shipping_addresses {
firstname
lastname
company
Expand All @@ -407,8 +421,8 @@ public function testSetSavedRegisteredCustomerShippingAddressOnCart()

self::assertArrayHasKey('cart', $response['setShippingAddressesOnCart']);
$cartResponse = $response['setShippingAddressesOnCart']['cart'];
self::assertArrayHasKey('addresses', $cartResponse);
$shippingAddressResponse = current($cartResponse['addresses']);
self::assertArrayHasKey('shipping_addresses', $cartResponse);
$shippingAddressResponse = current($cartResponse['shipping_addresses']);
$this->assertSavedShippingAddressFields($shippingAddressResponse);
}

Expand Down Expand Up @@ -466,4 +480,22 @@ private function getHeaderMap(string $username = 'customer@example.com'): array
$headerMap = ['Authorization' => 'Bearer ' . $customerToken];
return $headerMap;
}

public function tearDown()
{
/** @var \Magento\Config\Model\ResourceModel\Config $config */
$config = ObjectManager::getInstance()->get(\Magento\Config\Model\ResourceModel\Config::class);

//default state of multishipping config
$config->saveConfig(
Data::XML_PATH_CHECKOUT_MULTIPLE_AVAILABLE,
1,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
0
);

/** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */
$config = ObjectManager::getInstance()->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
$config->reinit();
}
}

0 comments on commit d0578be

Please sign in to comment.