|
10 | 10 | use Magento\Catalog\Api\Data\ProductInterface;
|
11 | 11 | use Magento\Catalog\Api\ProductRepositoryInterface;
|
12 | 12 | use Magento\Catalog\Block\Product\ListProduct;
|
| 13 | +use Magento\Catalog\Helper\Product\Flat\Indexer as IndexerHelper; |
13 | 14 | use Magento\Catalog\Model\CategoryFactory;
|
14 | 15 | use Magento\Catalog\Model\Indexer\Product\Flat\Processor;
|
15 | 16 | use Magento\Catalog\Model\Indexer\Product\Flat\State;
|
16 | 17 | use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
|
17 | 18 | use Magento\Catalog\Model\ResourceModel\Product\Flat as FlatResource;
|
18 | 19 | use Magento\CatalogSearch\Model\Indexer\Fulltext;
|
19 | 20 | use Magento\Eav\Api\AttributeOptionManagementInterface;
|
| 21 | +use Magento\Framework\Exception\LocalizedException; |
20 | 22 | use Magento\Framework\Indexer\IndexerRegistry;
|
21 | 23 | use Magento\Framework\ObjectManagerInterface;
|
22 | 24 | use Magento\Store\Model\StoreManagerInterface;
|
@@ -49,6 +51,9 @@ class FullTest extends TestCase
|
49 | 51 | /** @var Full */
|
50 | 52 | private $action;
|
51 | 53 |
|
| 54 | + /** @var IndexerHelper */ |
| 55 | + private $productIndexerHelper; |
| 56 | + |
52 | 57 | /**
|
53 | 58 | * @inheritdoc
|
54 | 59 | */
|
@@ -79,6 +84,7 @@ protected function setUp(): void
|
79 | 84 | $this->optionManagement = $this->objectManager->get(AttributeOptionManagementInterface::class);
|
80 | 85 | $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
|
81 | 86 | $this->action = $this->objectManager->get(Full::class);
|
| 87 | + $this->productIndexerHelper = $this->objectManager->get(IndexerHelper::class); |
82 | 88 | }
|
83 | 89 |
|
84 | 90 | /**
|
@@ -180,6 +186,28 @@ public function testCheckDropdownAttributeInFlat(): void
|
180 | 186 | $this->assertFlatColumnValue($attributeCode, $attributeValue);
|
181 | 187 | }
|
182 | 188 |
|
| 189 | + /** |
| 190 | + * @magentoDbIsolation disabled |
| 191 | + * |
| 192 | + * @magentoConfigFixture default/catalog/product/flat/max_index_count 1 |
| 193 | + * |
| 194 | + * @return void |
| 195 | + */ |
| 196 | + public function testWithTooManyIndexes(): void |
| 197 | + { |
| 198 | + $indexesNeed = count($this->productIndexerHelper->getFlatIndexes()); |
| 199 | + $message = (string)__( |
| 200 | + 'The Flat Catalog module has a limit of %2$d filterable and/or sortable attributes.' |
| 201 | + . 'Currently there are %1$d of them.' |
| 202 | + . 'Please reduce the number of filterable/sortable attributes in order to use this module', |
| 203 | + $indexesNeed, |
| 204 | + 1 |
| 205 | + ); |
| 206 | + $this->expectExceptionMessage($message); |
| 207 | + $this->expectException(LocalizedException::class); |
| 208 | + $this->action->execute(); |
| 209 | + } |
| 210 | + |
183 | 211 | /**
|
184 | 212 | * Assert if column exist and column value in flat table
|
185 | 213 | *
|
|
0 commit comments