10 use Symfony\Component\Console\Tester\CommandTester;
28 $optionsList = $this->command->getInputList();
29 $this->assertSame(2,
sizeof($optionsList));
30 $this->assertSame(
'mode', $optionsList[0]->getName());
31 $this->assertSame(
'index', $optionsList[1]->getName());
42 $commandTester =
new CommandTester($this->command);
43 $commandTester->execute([]);
54 $commandTester =
new CommandTester($this->command);
55 $commandTester->execute([
'mode' =>
'wrong_mode']);
61 $indexerOne = $this->getIndexerMock(
62 [
'isScheduled',
'setScheduled'],
63 [
'indexer_id' =>
'indexer_1',
'title' =>
'Title_indexerOne']
66 $indexerOne->expects($this->exactly(2))
67 ->method(
'isScheduled')
68 ->willReturnOnConsecutiveCalls([
true,
false]);
70 $indexerOne->expects($this->once())->method(
'setScheduled')->with(
false);
73 $this->indexerFactory->expects($this->never())->method(
'create');
75 $commandTester =
new CommandTester($this->command);
76 $commandTester->execute([
'mode' =>
'realtime']);
77 $actualValue = $commandTester->getDisplay();
79 'Index mode for Indexer Title_indexerOne was changed from '.
'\'Update by Schedule\
' to \'Update on Save\'' 96 $indexerOne = $this->getIndexerMock(
97 [
'isScheduled',
'setScheduled'],
98 [
'indexer_id' =>
'id_indexerOne',
'title' =>
'Title_indexerOne']
101 $indexerOne->expects($this->once())->method(
'setScheduled')->with($isScheduled);
102 $indexerOne->expects($this->exactly(2))
103 ->method(
'isScheduled')
104 ->willReturnOnConsecutiveCalls($previous, $current);
107 $commandTester =
new CommandTester($this->command);
108 $commandTester->execute([
'mode' =>
$mode,
'index' => [
'id_indexerOne']]);
109 $actualValue = $commandTester->getDisplay();
110 $this->assertSame($expectedValue, $actualValue);
124 'Index mode for Indexer Title_indexerOne was changed from \'Update by Schedule\' to \'Update on Save\'' 132 'Index mode for Indexer Title_indexerOne has not been changed' 140 'Index mode for Indexer Title_indexerOne has not been changed' 148 'Index mode for Indexer Title_indexerOne was changed from \'Update on Save\' to \'Update by Schedule\'' 157 $indexerOne = $this->getIndexerMock(
158 [
'isScheduled',
'setScheduled'],
159 [
'indexer_id' =>
'id_indexerOne']
161 $localizedException = new \Magento\Framework\Exception\LocalizedException(
__(
'Some Exception Message'));
162 $indexerOne->expects($this->once())->method(
'setScheduled')->will($this->throwException($localizedException));
165 $commandTester =
new CommandTester($this->command);
166 $commandTester->execute([
'mode' =>
'schedule',
'index' => [
'id_indexerOne']]);
167 $actualValue = $commandTester->getDisplay();
168 $this->assertStringStartsWith(
'Some Exception Message', $actualValue);
174 $indexerOne = $this->getIndexerMock(
175 [
'isScheduled',
'setScheduled'],
176 [
'indexer_id' =>
'id_indexerOne',
'title' =>
'Title_indexerOne']
178 $exception = new \Exception();
179 $indexerOne->expects($this->once())->method(
'setScheduled')->will($this->throwException($exception));
182 $commandTester =
new CommandTester($this->command);
183 $commandTester->execute([
'mode' =>
'schedule',
'index' => [
'id_indexerOne']]);
184 $actualValue = $commandTester->getDisplay();
185 $this->assertStringStartsWith(
'Title_indexerOne indexer process unknown error:', $actualValue);
testExecuteWithLocalizedException()
testExecuteWithIndex($isScheduled, $previous, $current, $mode, $expectedValue)
executeWithIndexDataProvider()
testExecuteWithException()
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
testExecuteInvalidArgument()
initIndexerCollectionByItems(array $items)