Skip to content

Commit c2467f2

Browse files
committed
ACP2E-94: When product is removed in Multiaddress checkout, the address dropdown value changes to default of all product.
IT for test coverage implemented
1 parent d556967 commit c2467f2

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Quote\Model;
99

1010
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Checkout\Model\Session as CheckoutSession;
1112
use Magento\Customer\Api\CustomerRepositoryInterface;
1213
use Magento\Customer\Api\Data\CustomerInterface;
1314
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
@@ -761,4 +762,46 @@ public function testValidateMinimumAmountWithPriceInclTaxAndDiscount()
761762
$this->assertEquals(5, $quote->getShippingAddress()->getBaseGrandTotal());
762763
$this->assertTrue($quote->validateMinimumAmount());
763764
}
765+
766+
/**
767+
* @magentoConfigFixture current_store multishipping/options/checkout_multiple 1
768+
* @magentoAppIsolation enabled
769+
* @magentoDbIsolation enabled
770+
* @magentoDataFixture Magento/Multishipping/Fixtures/quote_with_split_items.php
771+
* @return void
772+
*/
773+
public function testIsMultiShippingModeEnabledAfterQuoteItemRemoved(): void
774+
{
775+
$quote = $this->getQuoteByReservedOrderId->execute('multishipping_quote_id');
776+
/** @var CheckoutSession $session */
777+
$session = $this->objectManager->get(CheckoutSession::class);
778+
$session->replaceQuote($quote);
779+
$items = $quote->getAllItems();
780+
$idToDelete = null;
781+
foreach($items as $item) {
782+
if (!$item->getProduct()->isVirtual() && $item->getQty() == 1) {
783+
$idToDelete = $item->getId();
784+
}
785+
}
786+
787+
if (!is_null($idToDelete)) {
788+
$quoteShippingAddresses = $quote->getAllShippingAddresses();
789+
foreach($quoteShippingAddresses as $shippingAddress) {
790+
if ($shippingAddress->getItemById($idToDelete)) {
791+
$shippingAddress->removeItem($idToDelete);
792+
$shippingAddress->setCollectShippingRates(true);
793+
794+
if (count($shippingAddress->getAllItems()) == 0) {
795+
$shippingAddress->isDeleted(true);
796+
}
797+
}
798+
}
799+
$quote->removeItem($idToDelete);
800+
$this->assertEquals(1, $quote->getIsMultiShipping(),
801+
"Multi-shipping mode is disabled after quote item removal");
802+
} else {
803+
$this->assertTrue(!is_null($idToDelete),
804+
"No Simple Product item with qty 1 to delete exists");
805+
}
806+
}
764807
}

0 commit comments

Comments
 (0)