@@ -86,36 +86,60 @@ public function testExecuteWithIndex()
86
86
['id_indexer3 ' , ['title ' => 'Title_indexer3 ' , 'shared_index ' => 'with_indexer_3 ' ]]
87
87
]
88
88
));
89
+ $ this ->configMock ->expects ($ this ->any ())
90
+ ->method ('getIndexers ' )
91
+ ->will ($ this ->returnValue (
92
+ [
93
+ 'id_indexerOne ' => [
94
+ 'indexer_id ' => 'id_indexerOne ' ,
95
+ 'title ' => 'Title_indexerOne ' ,
96
+ 'shared_index ' => null
97
+ ],
98
+ 'id_indexerTwo ' => [
99
+ 'indexer_id ' => 'id_indexerTwo ' ,
100
+ 'title ' => 'Title_indexerTwo ' ,
101
+ 'shared_index ' => 'with_indexer_3 '
102
+ ],
103
+ 'id_indexer3 ' => [
104
+ 'indexer_id ' => 'id_indexer3 ' ,
105
+ 'title ' => 'Title_indexer3 ' ,
106
+ 'shared_index ' => 'with_indexer_3 '
107
+ ]
108
+ ]
109
+ ));
89
110
90
111
$ this ->configureAdminArea ();
91
112
$ indexerOne = $ this ->getMock ('Magento\Indexer\Model\Indexer ' , [], [], '' , false );
92
113
$ indexerOne ->expects ($ this ->once ())->method ('reindexAll ' );
93
114
$ indexerOne ->expects ($ this ->once ())->method ('getTitle ' )->willReturn ('Title_indexerOne ' );
94
115
$ indexerOne ->expects ($ this ->any ())->method ('getId ' )->willReturn ('id_indexerOne ' );
95
- $ indexerOne ->expects ($ this ->once ())->method ('load ' )->with ('id_indexerOne ' )->willReturn ($ indexerOne );
116
+ $ indexerOne ->expects ($ this ->any ())->method ('load ' )->with ('id_indexerOne ' )->willReturn ($ indexerOne );
96
117
97
118
$ indexerTwo = $ this ->getMock ('Magento\Indexer\Model\Indexer ' , [], [], '' , false );
98
119
$ indexerTwo ->expects ($ this ->once ())->method ('reindexAll ' );
99
120
$ indexerTwo ->expects ($ this ->once ())->method ('getTitle ' )->willReturn ('Title_indexerTwo ' );
100
121
$ indexerTwo ->expects ($ this ->any ())->method ('getId ' )->willReturn ('id_indexerTwo ' );
101
- $ indexerTwo ->expects ($ this ->once ())->method ('load ' )->with ('id_indexerTwo ' )->willReturn ($ indexerTwo );
122
+ $ indexerTwo ->expects ($ this ->any ())->method ('load ' )->with ('id_indexerTwo ' )->willReturn ($ indexerTwo );
102
123
103
124
$ indexer3 = $ this ->getMock ('Magento\Indexer\Model\Indexer ' , [], [], '' , false );
104
125
$ indexer3 ->expects ($ this ->never ())->method ('reindexAll ' );
105
126
$ indexer3 ->expects ($ this ->once ())->method ('getTitle ' )->willReturn ('Title_indexer3 ' );
106
127
$ indexer3 ->expects ($ this ->any ())->method ('getId ' )->willReturn ('id_indexer3 ' );
107
- $ indexer3 ->expects ($ this ->once ())->method ('load ' )->with ('id_indexer3 ' )->willReturn ($ indexer3 );
128
+ $ indexer3 ->expects ($ this ->any ())->method ('load ' )->with ('id_indexer3 ' )->willReturn ($ indexer3 );
108
129
109
130
$ stateMock = $ this ->getMock (\Magento \Indexer \Model \Indexer \State::class, [], [], '' , false );
110
- $ stateMock ->expects ($ this ->once ( ))->method ('setStatus ' )->will ($ this ->returnSelf ());
111
- $ stateMock ->expects ($ this ->once ( ))->method ('save ' );
131
+ $ stateMock ->expects ($ this ->exactly ( 2 ))->method ('setStatus ' )->will ($ this ->returnSelf ());
132
+ $ stateMock ->expects ($ this ->exactly ( 2 ))->method ('save ' );
112
133
113
134
$ indexer3 ->expects ($ this ->once ())->method ('getState ' )->willReturn ($ stateMock );
135
+ $ indexerTwo ->expects ($ this ->once ())->method ('getState ' )->willReturn ($ stateMock );
114
136
115
137
$ this ->collectionFactory ->expects ($ this ->never ())->method ('create ' );
116
138
$ this ->indexerFactory ->expects ($ this ->at (0 ))->method ('create ' )->willReturn ($ indexerOne );
117
139
$ this ->indexerFactory ->expects ($ this ->at (1 ))->method ('create ' )->willReturn ($ indexerTwo );
118
140
$ this ->indexerFactory ->expects ($ this ->at (2 ))->method ('create ' )->willReturn ($ indexer3 );
141
+ $ this ->indexerFactory ->expects ($ this ->at (3 ))->method ('create ' )->willReturn ($ indexerTwo );
142
+ $ this ->indexerFactory ->expects ($ this ->at (4 ))->method ('create ' )->willReturn ($ indexer3 );
119
143
120
144
$ this ->command = new IndexerReindexCommand ($ this ->objectManagerFactory );
121
145
$ commandTester = new CommandTester ($ this ->command );
0 commit comments