8
8
use Magento \Catalog \Api \ProductRepositoryInterface ;
9
9
use Magento \Catalog \Model \Indexer \Product \Price \Processor ;
10
10
use Magento \Framework \App \ResourceConnection ;
11
+ use Magento \Store \Api \WebsiteRepositoryInterface ;
11
12
use Magento \Store \Model \StoreManagerInterface ;
13
+ use Magento \TestFramework \Fixture \AppIsolation ;
14
+ use Magento \TestFramework \Fixture \DataFixture ;
15
+ use Magento \TestFramework \Fixture \DbIsolation ;
12
16
use Magento \TestFramework \Helper \Bootstrap ;
13
17
18
+ #[
19
+ DbIsolation(false ),
20
+ AppIsolation(true ),
21
+ ]
14
22
class IndexerBuilderTest extends \PHPUnit \Framework \TestCase
15
23
{
16
24
/**
@@ -58,6 +66,11 @@ class IndexerBuilderTest extends \PHPUnit\Framework\TestCase
58
66
*/
59
67
private $ indexProductProcessor ;
60
68
69
+ /**
70
+ * @var WebsiteRepositoryInterface
71
+ */
72
+ private $ websiteRepository ;
73
+
61
74
protected function setUp (): void
62
75
{
63
76
$ this ->indexerBuilder = Bootstrap::getObjectManager ()->get (
@@ -69,6 +82,7 @@ protected function setUp(): void
69
82
$ this ->productRepository = Bootstrap::getObjectManager ()->get (ProductRepositoryInterface::class);
70
83
$ this ->connection = Bootstrap::getObjectManager ()->get (ResourceConnection::class);
71
84
$ this ->indexProductProcessor = Bootstrap::getObjectManager ()->get (Processor::class);
85
+ $ this ->websiteRepository = Bootstrap::getObjectManager ()->get (WebsiteRepositoryInterface::class);
72
86
}
73
87
74
88
protected function tearDown (): void
@@ -93,8 +107,6 @@ protected function tearDown(): void
93
107
}
94
108
95
109
/**
96
- * @magentoDbIsolation disabled
97
- * @magentoAppIsolation enabled
98
110
* @magentoDataFixture Magento/CatalogRule/_files/attribute.php
99
111
* @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php
100
112
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
@@ -111,8 +123,6 @@ public function testReindexById()
111
123
}
112
124
113
125
/**
114
- * @magentoDbIsolation disabled
115
- * @magentoAppIsolation enabled
116
126
* @magentoDataFixture Magento/CatalogRule/_files/simple_product_with_catalog_rule_50_percent_off_tomorrow.php
117
127
* @magentoConfigFixture base_website general/locale/timezone Europe/Amsterdam
118
128
* @magentoConfigFixture general/locale/timezone America/Chicago
@@ -139,8 +149,6 @@ public function testReindexByIdDifferentTimezones()
139
149
}
140
150
141
151
/**
142
- * @magentoDbIsolation disabled
143
- * @magentoAppIsolation enabled
144
152
* @magentoDataFixture Magento/CatalogRule/_files/attribute.php
145
153
* @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php
146
154
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
@@ -166,8 +174,6 @@ public function testReindexByIds()
166
174
}
167
175
168
176
/**
169
- * @magentoDbIsolation disabled
170
- * @magentoAppIsolation enabled
171
177
* @magentoDataFixtureBeforeTransaction Magento/CatalogRule/_files/attribute.php
172
178
* @magentoDataFixtureBeforeTransaction Magento/CatalogRule/_files/rule_by_attribute.php
173
179
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
@@ -187,9 +193,6 @@ public function testReindexFull()
187
193
188
194
/**
189
195
* Tests restoring triggers on `catalogrule_product_price` table after full reindexing in 'Update by schedule' mode.
190
- *
191
- * @magentoDbIsolation disabled
192
- * @magentoAppIsolation enabled
193
196
*/
194
197
public function testRestoringTriggersAfterFullReindex ()
195
198
{
@@ -208,6 +211,42 @@ public function testRestoringTriggersAfterFullReindex()
208
211
$ this ->assertEquals (0 , $ this ->getTriggersCount ($ tableName ));
209
212
}
210
213
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
+
211
250
/**
212
251
* Returns triggers count.
213
252
*
0 commit comments