88use Magento \Catalog \Api \ProductRepositoryInterface ;
99use Magento \Catalog \Model \Indexer \Product \Price \Processor ;
1010use Magento \Framework \App \ResourceConnection ;
11+ use Magento \Store \Api \WebsiteRepositoryInterface ;
1112use Magento \Store \Model \StoreManagerInterface ;
13+ use Magento \TestFramework \Fixture \AppIsolation ;
14+ use Magento \TestFramework \Fixture \DataFixture ;
15+ use Magento \TestFramework \Fixture \DbIsolation ;
1216use Magento \TestFramework \Helper \Bootstrap ;
1317
18+ #[
19+ DbIsolation(false ),
20+ AppIsolation(true ),
21+ ]
1422class IndexerBuilderTest extends \PHPUnit \Framework \TestCase
1523{
1624 /**
@@ -58,6 +66,11 @@ class IndexerBuilderTest extends \PHPUnit\Framework\TestCase
5866 */
5967 private $ indexProductProcessor ;
6068
69+ /**
70+ * @var WebsiteRepositoryInterface
71+ */
72+ private $ websiteRepository ;
73+
6174 protected function setUp (): void
6275 {
6376 $ this ->indexerBuilder = Bootstrap::getObjectManager ()->get (
@@ -69,6 +82,7 @@ protected function setUp(): void
6982 $ this ->productRepository = Bootstrap::getObjectManager ()->get (ProductRepositoryInterface::class);
7083 $ this ->connection = Bootstrap::getObjectManager ()->get (ResourceConnection::class);
7184 $ this ->indexProductProcessor = Bootstrap::getObjectManager ()->get (Processor::class);
85+ $ this ->websiteRepository = Bootstrap::getObjectManager ()->get (WebsiteRepositoryInterface::class);
7286 }
7387
7488 protected function tearDown (): void
@@ -93,8 +107,6 @@ protected function tearDown(): void
93107 }
94108
95109 /**
96- * @magentoDbIsolation disabled
97- * @magentoAppIsolation enabled
98110 * @magentoDataFixture Magento/CatalogRule/_files/attribute.php
99111 * @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php
100112 * @magentoDataFixture Magento/Catalog/_files/product_simple.php
@@ -111,8 +123,6 @@ public function testReindexById()
111123 }
112124
113125 /**
114- * @magentoDbIsolation disabled
115- * @magentoAppIsolation enabled
116126 * @magentoDataFixture Magento/CatalogRule/_files/simple_product_with_catalog_rule_50_percent_off_tomorrow.php
117127 * @magentoConfigFixture base_website general/locale/timezone Europe/Amsterdam
118128 * @magentoConfigFixture general/locale/timezone America/Chicago
@@ -139,8 +149,6 @@ public function testReindexByIdDifferentTimezones()
139149 }
140150
141151 /**
142- * @magentoDbIsolation disabled
143- * @magentoAppIsolation enabled
144152 * @magentoDataFixture Magento/CatalogRule/_files/attribute.php
145153 * @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php
146154 * @magentoDataFixture Magento/Catalog/_files/product_simple.php
@@ -166,8 +174,6 @@ public function testReindexByIds()
166174 }
167175
168176 /**
169- * @magentoDbIsolation disabled
170- * @magentoAppIsolation enabled
171177 * @magentoDataFixtureBeforeTransaction Magento/CatalogRule/_files/attribute.php
172178 * @magentoDataFixtureBeforeTransaction Magento/CatalogRule/_files/rule_by_attribute.php
173179 * @magentoDataFixture Magento/Catalog/_files/product_simple.php
@@ -187,9 +193,6 @@ public function testReindexFull()
187193
188194 /**
189195 * Tests restoring triggers on `catalogrule_product_price` table after full reindexing in 'Update by schedule' mode.
190- *
191- * @magentoDbIsolation disabled
192- * @magentoAppIsolation enabled
193196 */
194197 public function testRestoringTriggersAfterFullReindex ()
195198 {
@@ -208,6 +211,42 @@ public function testRestoringTriggersAfterFullReindex()
208211 $ this ->assertEquals (0 , $ this ->getTriggersCount ($ tableName ));
209212 }
210213
214+ #[
215+ DataFixture('Magento/CatalogRule/_files/simple_product_with_catalog_rule_50_percent_off.php ' ),
216+ ]
217+ public function testReindexByIdForSecondStore (): void
218+ {
219+ $ websiteId = $ this ->websiteRepository ->get ('test ' )->getId ();
220+ $ simpleProduct = $ this ->productRepository ->get ('simple ' );
221+ $ this ->indexerBuilder ->reindexById ($ simpleProduct ->getId ());
222+ $ rulePrice = $ this ->resourceRule ->getRulePrice (new \DateTime (), $ websiteId , 1 , $ simpleProduct ->getId ());
223+ $ this ->assertEquals (25 , $ rulePrice );
224+ }
225+
226+ #[
227+ DataFixture('Magento/CatalogRule/_files/simple_product_with_catalog_rule_50_percent_off.php ' ),
228+ ]
229+ public function testReindexByIdsForSecondStore (): void
230+ {
231+ $ websiteId = $ this ->websiteRepository ->get ('test ' )->getId ();
232+ $ simpleProduct = $ this ->productRepository ->get ('simple ' );
233+ $ this ->indexerBuilder ->reindexByIds ([$ simpleProduct ->getId ()]);
234+ $ rulePrice = $ this ->resourceRule ->getRulePrice (new \DateTime (), $ websiteId , 1 , $ simpleProduct ->getId ());
235+ $ this ->assertEquals (25 , $ rulePrice );
236+ }
237+
238+ #[
239+ DataFixture('Magento/CatalogRule/_files/simple_product_with_catalog_rule_50_percent_off.php ' ),
240+ ]
241+ public function testReindexFullForSecondStore (): void
242+ {
243+ $ websiteId = $ this ->websiteRepository ->get ('test ' )->getId ();
244+ $ simpleProduct = $ this ->productRepository ->get ('simple ' );
245+ $ this ->indexerBuilder ->reindexFull ();
246+ $ rulePrice = $ this ->resourceRule ->getRulePrice (new \DateTime (), $ websiteId , 1 , $ simpleProduct ->getId ());
247+ $ this ->assertEquals (25 , $ rulePrice );
248+ }
249+
211250 /**
212251 * Returns triggers count.
213252 *
0 commit comments