|
17 | 17 |
|
18 | 18 | /**
|
19 | 19 | * @magentoDbIsolation disabled
|
20 |
| - * @magentoAppIsolation enabled |
21 | 20 | * @magentoAppArea adminhtml
|
22 |
| - * @magentoDataFixture Magento/Catalog/_files/categories_no_products.php |
23 | 21 | * @magentoDataFixture Magento/CatalogRuleConfigurable/_files/configurable_product_with_percent_rule.php
|
24 |
| - * @magentoDataFixture Magento/CatalogRuleConfigurable/_files/configurable_product_with_categories_rule.php |
25 | 22 | */
|
26 | 23 | class ProductRuleIndexerTest extends TestCase
|
27 | 24 | {
|
@@ -52,116 +49,51 @@ protected function setUp(): void
|
52 | 49 | }
|
53 | 50 |
|
54 | 51 | /**
|
55 |
| - * @dataProvider productsDataProvider |
56 |
| - * @param string $reindexSku |
57 |
| - * @param array $expectedPrices |
58 | 52 | * @return void
|
59 |
| - * @throws \Magento\Framework\Exception\NoSuchEntityException |
60 | 53 | */
|
61 |
| - public function testExecute(string $reindexSku, array $expectedPrices): void |
| 54 | + public function testExecute(): void |
62 | 55 | {
|
63 |
| - $product = $this->productRepository->get($reindexSku); |
| 56 | + $product = $this->productRepository->get('configurable'); |
64 | 57 | $this->productRuleIndexer->execute([$product->getId()]);
|
65 | 58 |
|
66 |
| - $this->assertEquals($expectedPrices, $this->getCatalogRulePrices(array_keys($expectedPrices))); |
| 59 | + $product = $this->productRepository->get('simple_10'); |
| 60 | + $price = $this->getCatalogRulePrice($product); |
| 61 | + $this->assertEquals(5, $price); |
67 | 62 | }
|
68 | 63 |
|
69 | 64 | /**
|
70 |
| - * @dataProvider productsDataProvider |
71 |
| - * @param string $reindexSku |
72 |
| - * @param array $expectedPrices |
73 | 65 | * @return void
|
74 |
| - * @throws \Magento\Framework\Exception\LocalizedException |
75 |
| - * @throws \Magento\Framework\Exception\NoSuchEntityException |
76 | 66 | */
|
77 |
| - public function testExecuteRow(string $reindexSku, array $expectedPrices): void |
| 67 | + public function testExecuteRow(): void |
78 | 68 | {
|
79 |
| - $product = $this->productRepository->get($reindexSku); |
| 69 | + $product = $this->productRepository->get('configurable'); |
80 | 70 | $this->productRuleIndexer->executeRow($product->getId());
|
81 | 71 |
|
82 |
| - $this->assertEquals($expectedPrices, $this->getCatalogRulePrices(array_keys($expectedPrices))); |
| 72 | + $product = $this->productRepository->get('simple_10'); |
| 73 | + $price = $this->getCatalogRulePrice($product); |
| 74 | + $this->assertEquals(5, $price); |
83 | 75 | }
|
84 | 76 |
|
85 | 77 | /**
|
86 |
| - * @dataProvider productsDataProvider |
87 |
| - * @param string $reindexSku |
88 |
| - * @param array $expectedPrices |
89 | 78 | * @return void
|
90 |
| - * @throws \Magento\Framework\Exception\LocalizedException |
91 |
| - * @throws \Magento\Framework\Exception\NoSuchEntityException |
92 | 79 | */
|
93 |
| - public function testExecuteList(string $reindexSku, array $expectedPrices): void |
| 80 | + public function testExecuteList(): void |
94 | 81 | {
|
95 |
| - $product = $this->productRepository->get($reindexSku); |
| 82 | + $product = $this->productRepository->get('configurable'); |
96 | 83 | $this->productRuleIndexer->executeList([$product->getId()]);
|
97 | 84 |
|
98 |
| - $this->assertEquals($expectedPrices, $this->getCatalogRulePrices(array_keys($expectedPrices))); |
| 85 | + $product = $this->productRepository->get('simple_10'); |
| 86 | + $price = $this->getCatalogRulePrice($product); |
| 87 | + $this->assertEquals(5, $price); |
99 | 88 | }
|
100 | 89 |
|
101 |
| - /** |
102 |
| - * @return void |
103 |
| - */ |
104 | 90 | public function testExecuteFull(): void
|
105 | 91 | {
|
106 | 92 | $this->productRuleIndexer->executeFull();
|
107 | 93 |
|
108 |
| - $expectedPrices = [ |
109 |
| - 'simple_10' => 5, |
110 |
| - 'simple_20' => 10, |
111 |
| - 'simple_30' => 15, |
112 |
| - 'simple_40' => 20, |
113 |
| - ]; |
114 |
| - $this->assertEquals($expectedPrices, $this->getCatalogRulePrices(array_keys($expectedPrices))); |
115 |
| - } |
116 |
| - |
117 |
| - /** |
118 |
| - * @return array |
119 |
| - */ |
120 |
| - public function productsDataProvider(): array |
121 |
| - { |
122 |
| - return [ |
123 |
| - [ |
124 |
| - 'configurable', |
125 |
| - [ |
126 |
| - 'simple_10' => 5, |
127 |
| - 'simple_20' => 10, |
128 |
| - ] |
129 |
| - ], |
130 |
| - [ |
131 |
| - 'simple_10', |
132 |
| - [ |
133 |
| - 'simple_10' => 5, |
134 |
| - ] |
135 |
| - ], |
136 |
| - [ |
137 |
| - '12345', |
138 |
| - [ |
139 |
| - 'simple_30' => 15, |
140 |
| - 'simple_40' => 20, |
141 |
| - ] |
142 |
| - ], |
143 |
| - [ |
144 |
| - 'simple_30', |
145 |
| - [ |
146 |
| - 'simple_30' => 15, |
147 |
| - ] |
148 |
| - ], |
149 |
| - ]; |
150 |
| - } |
151 |
| - |
152 |
| - /** |
153 |
| - * @param array $skus |
154 |
| - * @return array |
155 |
| - * @throws \Magento\Framework\Exception\NoSuchEntityException |
156 |
| - */ |
157 |
| - private function getCatalogRulePrices(array $skus): array |
158 |
| - { |
159 |
| - $actualPrices = []; |
160 |
| - foreach ($skus as $sku) { |
161 |
| - $product = $this->productRepository->get($sku); |
162 |
| - $actualPrices[$sku] = $this->getCatalogRulePrice($product); |
163 |
| - } |
164 |
| - return $actualPrices; |
| 94 | + $product = $this->productRepository->get('simple_10'); |
| 95 | + $price = $this->getCatalogRulePrice($product); |
| 96 | + $this->assertEquals(5, $price); |
165 | 97 | }
|
166 | 98 |
|
167 | 99 | /**
|
|
0 commit comments