@@ -112,18 +112,19 @@ public function testProcessBatchHandlesDeltaIndexingPaged()
112
112
$ this ->setupBasicIndexingConfig ($ pageSize );
113
113
$ this ->productHelper ->method ('getParentProductIds ' )->willReturn ([]);
114
114
115
- $ invocations = $ this -> exactly ( 5 ) ;
116
- $ this ->queue ->expects ($ invocations )
115
+ $ invocationCount = 0 ;
116
+ $ this ->queue ->expects ($ this -> exactly ( 5 ) )
117
117
->method ('addToQueue ' )
118
118
->with (
119
119
IndexBuilder::class,
120
120
'buildIndexList ' ,
121
- $ this ->callback (function (array $ arg ) use ($ invocations , $ pageSize ) {
121
+ $ this ->callback (function (array $ arg ) use (&$ invocationCount , $ pageSize ) {
122
+ $ invocationCount ++;
122
123
return array_key_exists ('storeId ' , $ arg )
123
124
&& array_key_exists ('entityIds ' , $ arg )
124
125
&& array_key_exists ('options ' , $ arg )
125
126
&& $ arg ['options ' ]['pageSize ' ] === $ pageSize
126
- && $ arg ['options ' ]['page ' ] === $ invocations -> getInvocationCount () ;
127
+ && $ arg ['options ' ]['page ' ] === $ invocationCount ;
127
128
})
128
129
);
129
130
@@ -142,8 +143,8 @@ public function testProcessBatchHandlesFullIndexing()
142
143
$ this ->productHelper ->method ('getProductCollectionQuery ' )->willReturn ($ this ->getMockCollection ());
143
144
$ this ->queueHelper ->method ('useTmpIndex ' )->willReturn (false );
144
145
145
- $ invocations = $ this -> exactly ( 2 ) ;
146
- $ this ->queue ->expects ($ invocations )
146
+ $ invocationCount = 0 ;
147
+ $ this ->queue ->expects ($ this -> exactly ( 2 ) )
147
148
->method ('addToQueue ' )
148
149
->willReturnCallback (
149
150
function (
@@ -152,8 +153,9 @@ function(
152
153
array $ data ,
153
154
int $ dataSize ,
154
155
bool $ isFullReindex )
155
- use ($ invocations ) {
156
- switch ($ invocations ->getInvocationCount ()) {
156
+ use (&$ invocationCount ) {
157
+ $ invocationCount ++;
158
+ switch ($ invocationCount ) {
157
159
case 1 :
158
160
$ this ->assertEquals (IndicesConfigurator::class, $ className );
159
161
$ this ->assertEquals ('saveConfigurationToAlgolia ' , $ method );
@@ -202,8 +204,8 @@ public function testProcessBatchHandlesFullIndexingPaged()
202
204
$ this ->productHelper ->method ('getProductCollectionQuery ' )->willReturn ($ this ->getMockCollection ());
203
205
$ this ->queueHelper ->method ('useTmpIndex ' )->willReturn (false );
204
206
205
- $ invocations = $ this -> exactly ( 6 ) ;
206
- $ this ->queue ->expects ($ invocations )
207
+ $ invocationCount = 0 ;
208
+ $ this ->queue ->expects ($ this -> exactly ( 6 ) )
207
209
->method ('addToQueue ' )
208
210
->willReturnCallback (
209
211
function (
@@ -212,9 +214,9 @@ function(
212
214
array $ data ,
213
215
int $ dataSize ,
214
216
bool $ isFullReindex )
215
- use ($ invocations , $ pageSize ) {
216
- $ invocation = $ invocations -> getInvocationCount () ;
217
- switch ($ invocation ) {
217
+ use (& $ invocationCount , $ pageSize ) {
218
+ $ invocationCount ++ ;
219
+ switch ($ invocationCount ) {
218
220
case 1 :
219
221
$ this ->assertEquals (IndicesConfigurator::class, $ className );
220
222
$ this ->assertEquals ('saveConfigurationToAlgolia ' , $ method );
@@ -224,7 +226,7 @@ function(
224
226
$ this ->assertEquals ('buildIndexFull ' , $ method );
225
227
$ this ->assertArrayHasKey ('options ' , $ data );
226
228
$ this ->assertEquals ($ pageSize , $ data ['options ' ]['pageSize ' ]);
227
- $ this ->assertEquals ($ invocation - 1 , $ data ['options ' ]['page ' ]);
229
+ $ this ->assertEquals ($ invocationCount - 1 , $ data ['options ' ]['page ' ]);
228
230
break ;
229
231
}
230
232
}
@@ -249,8 +251,8 @@ public function testProcessBatchMovesTempIndexIfQueueActive()
249
251
250
252
$ this ->queueHelper ->method ('useTmpIndex ' )->willReturn (true );
251
253
252
- $ invocations = $ this -> exactly ( 3 ) ;
253
- $ this ->queue ->expects ($ invocations )
254
+ $ invocationCount = 0 ;
255
+ $ this ->queue ->expects ($ this -> exactly ( 3 ) )
254
256
->method ('addToQueue ' )
255
257
->willReturnCallback (
256
258
function (
@@ -259,8 +261,9 @@ function(
259
261
array $ data ,
260
262
int $ dataSize ,
261
263
bool $ isFullReindex )
262
- use ($ invocations ) {
263
- if ($ invocations ->getInvocationCount () === 3 ) {
264
+ use (&$ invocationCount ) {
265
+ $ invocationCount ++;
266
+ if ($ invocationCount === 3 ) {
264
267
$ this ->assertEquals (IndexMover::class, $ className );
265
268
$ this ->assertEquals ('moveIndexWithSetSettings ' , $ method );
266
269
$ this ->assertArrayHasKey ('tmpIndexName ' , $ data );
0 commit comments