Skip to content

Commit 05788bb

Browse files
committed
Merge branch 'patch-1' of github.com:convenient/mtwo into 2.4-develop-prs
2 parents a70c62e + 24917fe commit 05788bb

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
use Symfony\Component\Console\Input\InputInterface;
1111
use Symfony\Component\Console\Output\OutputInterface;
1212
use Magento\Framework\Indexer\ConfigInterface;
13+
use Magento\Framework\Console\Cli;
1314

1415
/**
1516
* Command for invalidating indexers.
1617
*/
1718
class IndexerResetStateCommand extends AbstractIndexerManageCommand
1819
{
1920
/**
20-
* {@inheritdoc}
21+
* Configures the current command.
2122
*/
2223
protected function configure()
2324
{
@@ -29,16 +30,18 @@ protected function configure()
2930
}
3031

3132
/**
32-
* {@inheritdoc}
33+
* Invalidate / reset the indexer
34+
*
35+
* @param InputInterface $input
36+
* @param OutputInterface $output
37+
* @return int
3338
*/
3439
protected function execute(InputInterface $input, OutputInterface $output)
3540
{
3641
$indexers = $this->getIndexers($input);
3742
foreach ($indexers as $indexer) {
3843
try {
39-
$indexer->getState()
40-
->setStatus(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID)
41-
->save();
44+
$indexer->invalidate();
4245
$output->writeln($indexer->getTitle() . ' indexer has been invalidated.');
4346
} catch (LocalizedException $e) {
4447
$output->writeln($e->getMessage());
@@ -47,5 +50,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
4750
$output->writeln($e->getMessage());
4851
}
4952
}
53+
return Cli::RETURN_SUCCESS;
5054
}
5155
}

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,17 @@ class IndexerResetStateCommandTest extends AbstractIndexerCommandCommonSetup
2222
*/
2323
private $command;
2424

25-
protected function setUp(): void
26-
{
27-
parent::setUp();
28-
$this->stateMock->expects($this->once())->method('setAreaCode')->with(FrontNameResolver::AREA_CODE);
29-
}
30-
3125
public function testExecute()
3226
{
3327
$this->configureAdminArea();
3428
$indexerOne = $this->getIndexerMock(
35-
['getState'],
29+
['invalidate'],
3630
['indexer_id' => 'indexer_1', 'title' => 'Title_indexerOne']
3731
);
3832
$this->initIndexerCollectionByItems([$indexerOne]);
3933

40-
$stateMock = $this->createMock(State::class);
41-
$stateMock->expects($this->exactly(1))
42-
->method('setStatus')
43-
->with(StateInterface::STATUS_INVALID)->willReturnSelf();
44-
45-
$stateMock->expects($this->exactly(1))
46-
->method('save');
47-
4834
$indexerOne->expects($this->once())
49-
->method('getState')
50-
->willReturn($stateMock);
35+
->method('invalidate');
5136

5237
$this->command = new IndexerResetStateCommand($this->objectManagerFactory);
5338
$commandTester = new CommandTester($this->command);

0 commit comments

Comments
 (0)