diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/SetShippingAddressOnCartTest.php index a023d37895c23..d60876e7c0be4 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/SetShippingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/SetShippingAddressOnCartTest.php @@ -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; @@ -79,7 +81,7 @@ public function testSetNewGuestShippingAddressOnCart() } ) { cart { - addresses { + shipping_addresses { firstname lastname company @@ -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); } @@ -126,7 +128,7 @@ public function testSetSavedShippingAddressOnCartByGuest() } ) { cart { - addresses { + shipping_addresses { firstname lastname company @@ -171,7 +173,7 @@ public function testSetMultipleShippingAddressesOnCartByGuest() } ) { cart { - addresses { + shipping_addresses { firstname lastname company @@ -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); } @@ -225,7 +239,7 @@ public function testSetSavedAndNewShippingAddressOnCartAtTheSameTime() } ) { cart { - addresses { + shipping_addresses { firstname lastname company @@ -267,7 +281,7 @@ public function testSetShippingAddressOnCartWithNoAddresses() } ) { cart { - addresses { + shipping_addresses { firstname lastname company @@ -332,7 +346,7 @@ public function testSetNewRegisteredCustomerShippingAddressOnCart() } ) { cart { - addresses { + shipping_addresses { firstname lastname company @@ -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); } @@ -390,7 +404,7 @@ public function testSetSavedRegisteredCustomerShippingAddressOnCart() } ) { cart { - addresses { + shipping_addresses { firstname lastname company @@ -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); } @@ -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(); + } }