-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/MC-35008' into 2.4-develop-pr32
- Loading branch information
Showing
2 changed files
with
101 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
dev/tests/integration/testsuite/Magento/Quote/Model/Product/Plugin/UpdateQuoteItemsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Quote\Model\Product\Plugin; | ||
|
||
use Magento\Catalog\Model\ProductRepository; | ||
use Magento\Framework\DB\Adapter\AdapterInterface; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Tests for update quote items plugin | ||
* | ||
* @magentoAppArea adminhtml | ||
*/ | ||
class UpdateQuoteItemsTest extends TestCase | ||
{ | ||
/** | ||
* @var GetQuoteByReservedOrderId | ||
*/ | ||
private $getQuoteByReservedOrderId; | ||
|
||
/** | ||
* @var ProductRepository | ||
*/ | ||
private $productRepository; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$objectManager = Bootstrap::getObjectManager(); | ||
$this->getQuoteByReservedOrderId = $objectManager->get(GetQuoteByReservedOrderId::class); | ||
$this->productRepository = $objectManager->get(ProductRepository::class); | ||
} | ||
|
||
/** | ||
* Test to mark the quote as need to recollect and doesn't update the field "updated_at" after change product price | ||
* | ||
* @magentoDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php | ||
* @return void | ||
*/ | ||
public function testMarkQuoteRecollectAfterChangeProductPrice(): void | ||
{ | ||
$quote = $this->getQuoteByReservedOrderId->execute('test_order_with_simple_product_without_address'); | ||
$this->assertNotNull($quote); | ||
$this->assertFalse((bool)$quote->getTriggerRecollect()); | ||
$this->assertNotEmpty($quote->getItems()); | ||
$quoteItem = current($quote->getItems()); | ||
$product = $quoteItem->getProduct(); | ||
|
||
$product->setPrice((float)$product->getPrice() + 10); | ||
$this->productRepository->save($product); | ||
|
||
/** @var AdapterInterface $connection */ | ||
$connection = $quote->getResource()->getConnection(); | ||
$select = $connection->select() | ||
->from( | ||
$connection->getTableName('quote'), | ||
['updated_at', 'trigger_recollect'] | ||
)->where( | ||
"reserved_order_id = 'test_order_with_simple_product_without_address'" | ||
); | ||
|
||
$quoteRow = $connection->fetchRow($select); | ||
$this->assertNotEmpty($quoteRow); | ||
$this->assertTrue((bool)$quoteRow['trigger_recollect']); | ||
$this->assertEquals($quote->getUpdatedAt(), $quoteRow['updated_at']); | ||
} | ||
} |