Skip to content

Commit a300380

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into ims-phase1
2 parents d21a94b + 7e794ce commit a300380

File tree

4 files changed

+64
-13
lines changed

4 files changed

+64
-13
lines changed

app/code/Magento/Indexer/Console/Command/IndexerShowDimensionsModeCommand.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
*/
2020
class IndexerShowDimensionsModeCommand extends AbstractIndexerCommand
2121
{
22-
const INPUT_KEY_INDEXER = 'indexer';
23-
const DIMENSION_MODE_NONE = 'none';
24-
const XML_PATH_DIMENSIONS_MODE_MASK = 'indexer/%s/dimensions_mode';
22+
private const INPUT_KEY_INDEXER = 'indexer';
23+
private const DIMENSION_MODE_NONE = 'none';
24+
private const XML_PATH_DIMENSIONS_MODE_MASK = 'indexer/%s/dimensions_mode';
2525
/**
2626
* @var string
2727
*/
@@ -36,24 +36,31 @@ class IndexerShowDimensionsModeCommand extends AbstractIndexerCommand
3636
* @var string[]
3737
*/
3838
private $indexers;
39+
/**
40+
* @var string[]
41+
*/
42+
private $optionalIndexers;
3943

4044
/**
4145
* @param ObjectManagerFactory $objectManagerFactory
4246
* @param ScopeConfigInterface $configReader
4347
* @param array $indexers
48+
* @param array $optionalIndexers
4449
*/
4550
public function __construct(
4651
ObjectManagerFactory $objectManagerFactory,
4752
ScopeConfigInterface $configReader,
48-
array $indexers
53+
array $indexers,
54+
array $optionalIndexers = []
4955
) {
5056
$this->configReader = $configReader;
5157
$this->indexers = $indexers;
58+
$this->optionalIndexers = $optionalIndexers;
5259
parent::__construct($objectManagerFactory);
5360
}
5461

5562
/**
56-
* {@inheritdoc}
63+
* @inheritdoc
5764
*/
5865
protected function configure()
5966
{
@@ -64,7 +71,7 @@ protected function configure()
6471
}
6572

6673
/**
67-
* {@inheritdoc}
74+
* @inheritdoc
6875
* @param InputInterface $input
6976
* @param OutputInterface $output
7077
* @return int
@@ -92,10 +99,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
9299
$output->writeln(sprintf('%-50s ', $indexer->getTitle() . ':') . $mode);
93100
}
94101
} catch (\Exception $e) {
95-
$output->writeln('"' . $indexer->getTitle() . '" indexer process unknown error:' . PHP_EOL);
96-
$output->writeln($e->getMessage() . PHP_EOL);
97-
// we must have an exit code higher than zero to indicate something was wrong
98-
$returnValue = Cli::RETURN_FAILURE;
102+
if (!in_array($indexerId, $this->optionalIndexers)) { /** @phpstan-ignore-line */
103+
$output->writeln('"' . $indexer->getTitle() . '" indexer process unknown error:' . PHP_EOL);
104+
$output->writeln($e->getMessage() . PHP_EOL);
105+
// we must have an exit code higher than zero to indicate something was wrong
106+
$returnValue = Cli::RETURN_FAILURE;
107+
}
99108
}
100109

101110
return $returnValue;
@@ -112,7 +121,7 @@ private function getInputList(): array
112121
$arguments[] = new InputArgument(
113122
self::INPUT_KEY_INDEXER,
114123
InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
115-
$optionDescription . ' (' . implode($this->indexers) . ')'
124+
$optionDescription . ' (' . implode(',', $this->indexers) . ')'
116125
);
117126

118127
return $arguments;

app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerShowDimensionsModeCommandTest.php

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,26 @@ class IndexerShowDimensionsModeCommandTest extends AbstractIndexerCommandCommonS
4141
*/
4242
private $indexerMock;
4343

44+
/**
45+
* @var string[]
46+
*/
47+
private $optionalIndexers;
48+
49+
/**
50+
* @var ObjectManagerHelper
51+
*/
52+
private $objectManagerHelper;
53+
4454
/**
4555
* @inheritdoc
4656
*/
4757
protected function setUp(): void
4858
{
4959
parent::setUp();
50-
$objectManagerHelper = new ObjectManagerHelper($this);
60+
$this->objectManagerHelper = new ObjectManagerHelper($this);
5161
$this->configReaderMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
5262
$this->indexers = ['indexer_1' => 'indexer_1', 'indexer_2' => 'indexer_2'];
53-
$this->command = $objectManagerHelper->getObject(
63+
$this->command = $this->objectManagerHelper->getObject(
5464
IndexerShowDimensionsModeCommand::class,
5565
[
5666
'objectManagerFactory' => $this->objectManagerFactory,
@@ -98,6 +108,29 @@ public function testExecuteWithAttributes($command, $consoleOutput)
98108
);
99109
}
100110

111+
public function testExecuteWithOptionalIndexers()
112+
{
113+
$this->optionalIndexers = ['indexer_3'];
114+
$this->indexers = ['indexer_3'=> 'indexer_3'];
115+
$this->command = $this->objectManagerHelper->getObject(
116+
IndexerShowDimensionsModeCommand::class,
117+
[
118+
'objectManagerFactory' => $this->objectManagerFactory,
119+
'configReader' => $this->configReaderMock,
120+
'indexers' => $this->indexers,
121+
'optionalIndexers' => $this->optionalIndexers
122+
]
123+
);
124+
$command = ['indexer' => ['indexer_3']];
125+
$this->configureAdminArea();
126+
/** @var CommandTester $commandTester */
127+
$commandTester = new CommandTester($this->command);
128+
$this->indexerMock->method('load')->willThrowException(new \InvalidArgumentException());
129+
$commandTester->execute($command);
130+
$actualValue = $commandTester->getDisplay();
131+
$this->assertEquals('', $actualValue);
132+
}
133+
101134
/**
102135
* @return array
103136
*/

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/Category/Plugin/StorageTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Catalog\Model\Product\Media\ConfigInterface;
1313
use Magento\Framework\App\Bootstrap as AppBootstrap;
1414
use Magento\Framework\App\Filesystem\DirectoryList;
15+
use Magento\Framework\App\ResourceConnection;
1516
use Magento\Framework\Exception\NoSuchEntityException;
1617
use Magento\Framework\Filesystem;
1718
use Magento\Framework\Filesystem\Driver\File;
@@ -139,6 +140,9 @@ private function removeFiles(): void
139140
*/
140141
private function removeProducts(): void
141142
{
143+
$resource = $this->objectManager->get(ResourceConnection::class);
144+
$connection = $resource->getConnection();
145+
$connection->delete('catalog_category_product');
142146
foreach ($this->createdProductsSkus as $sku) {
143147
try {
144148
$this->productRepository->deleteById($sku);

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
use Magento\Catalog\Model\CategoryRepository;
1212
use Magento\Catalog\Model\ProductRepository;
1313
use Magento\CatalogUrlRewrite\Model\ResourceModel\Category\Product;
14+
use Magento\Framework\App\ResourceConnection;
1415
use Magento\Framework\Exception\CouldNotSaveException;
1516
use Magento\Framework\Exception\LocalizedException;
1617
use Magento\Framework\Exception\NoSuchEntityException;
1718
use Magento\Framework\ObjectManagerInterface;
1819
use Magento\TestFramework\Helper\Bootstrap;
1920
use Magento\UrlRewrite\Model\OptionProvider;
21+
use Magento\UrlRewrite\Model\Storage\DbStorage;
2022
use Magento\UrlRewrite\Model\UrlFinderInterface;
2123
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
2224
use PHPUnit\Framework\Exception;
@@ -44,6 +46,9 @@ protected function setUp(): void
4446
*/
4547
public function testGenerateUrlRewritesWithoutSaveHistory()
4648
{
49+
$resource = $this->objectManager->get(ResourceConnection::class);
50+
$connection = $resource->getConnection();
51+
$connection->delete(DbStorage::TABLE_NAME);
4752
/** @var Category $category */
4853
$category = $this->objectManager->create(Category::class);
4954
$category->load(3);

0 commit comments

Comments
 (0)