Skip to content

Commit a9d1914

Browse files
committed
MC-38168: Manual Indexer after Merchandising - Empty Catalog/ Number of products incorrect
1 parent 88d6037 commit a9d1914

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Indexer\Model\Indexer\CollectionFactory;
1818
use Magento\Indexer\Model\Indexer\State;
1919
use Magento\Indexer\Model\Indexer\StateFactory;
20+
use Magento\Indexer\Model\WorkingStateProvider;
2021
use PHPUnit\Framework\MockObject\MockObject;
2122
use PHPUnit\Framework\TestCase;
2223

@@ -55,8 +56,16 @@ class IndexerTest extends TestCase
5556
*/
5657
protected $indexFactoryMock;
5758

59+
/**
60+
* @var WorkingStateProvider|MockObject
61+
*/
62+
private $workingStateProvider;
63+
5864
protected function setUp(): void
5965
{
66+
$this->workingStateProvider = $this->getMockBuilder(WorkingStateProvider::class)
67+
->disableOriginalConstructor()
68+
->getMock();
6069
$this->configMock = $this->getMockForAbstractClass(
6170
ConfigInterface::class,
6271
[],
@@ -99,7 +108,8 @@ protected function setUp(): void
99108
$structureFactory,
100109
$this->viewMock,
101110
$this->stateFactoryMock,
102-
$this->indexFactoryMock
111+
$this->indexFactoryMock,
112+
$this->workingStateProvider
103113
);
104114
}
105115

@@ -211,7 +221,7 @@ public function testReindexAll()
211221
$stateMock->expects($this->never())->method('setIndexerId');
212222
$stateMock->expects($this->once())->method('getId')->willReturn(1);
213223
$stateMock->expects($this->exactly(2))->method('setStatus')->willReturnSelf();
214-
$stateMock->expects($this->once())->method('getStatus')->willReturn('idle');
224+
$stateMock->expects($this->any())->method('getStatus')->willReturn('idle');
215225
$stateMock->expects($this->exactly(2))->method('save')->willReturnSelf();
216226
$this->stateFactoryMock->expects($this->once())->method('create')->willReturn($stateMock);
217227

@@ -251,7 +261,7 @@ public function testReindexAllWithException()
251261
$stateMock->expects($this->never())->method('setIndexerId');
252262
$stateMock->expects($this->once())->method('getId')->willReturn(1);
253263
$stateMock->expects($this->exactly(2))->method('setStatus')->willReturnSelf();
254-
$stateMock->expects($this->once())->method('getStatus')->willReturn('idle');
264+
$stateMock->expects($this->any())->method('getStatus')->willReturn('idle');
255265
$stateMock->expects($this->exactly(2))->method('save')->willReturnSelf();
256266
$this->stateFactoryMock->expects($this->once())->method('create')->willReturn($stateMock);
257267

@@ -296,7 +306,7 @@ public function testReindexAllWithError()
296306
$stateMock->expects($this->never())->method('setIndexerId');
297307
$stateMock->expects($this->once())->method('getId')->willReturn(1);
298308
$stateMock->expects($this->exactly(2))->method('setStatus')->willReturnSelf();
299-
$stateMock->expects($this->once())->method('getStatus')->willReturn('idle');
309+
$stateMock->expects($this->any())->method('getStatus')->willReturn('idle');
300310
$stateMock->expects($this->exactly(2))->method('save')->willReturnSelf();
301311
$this->stateFactoryMock->expects($this->once())->method('create')->willReturn($stateMock);
302312

0 commit comments

Comments
 (0)