@@ -146,22 +146,21 @@ public function testRun(
146146 ) {
147147 $ consumerName = 'consumerName ' ;
148148
149- $ this ->deploymentConfigMock -> expects ( $ this -> exactly ( 3 ))
149+ $ this ->deploymentConfigMock
150150 ->method ('get ' )
151151 ->willReturnMap (
152152 [
153153 ['cron_consumers_runner/cron_run ' , true , true ],
154154 ['cron_consumers_runner/max_messages ' , 10000 , $ maxMessages ],
155155 ['cron_consumers_runner/consumers ' , [], $ allowedConsumers ],
156+ ['queue/only_spawn_when_message_available ' , 0 , 0 ],
156157 ]
157158 );
158159
159160 /** @var ConsumerConfigInterface|MockObject $firstCunsumer */
160161 $ consumer = $ this ->getMockBuilder (ConsumerConfigItemInterface::class)
161162 ->getMockForAbstractClass ();
162- $ consumer ->expects ($ this ->any ())
163- ->method ('getName ' )
164- ->willReturn ($ consumerName );
163+ $ consumer ->method ('getName ' )->willReturn ($ consumerName );
165164
166165 $ this ->phpExecutableFinderMock ->expects ($ this ->once ())
167166 ->method ('find ' )
@@ -276,39 +275,40 @@ public function runDataProvider()
276275 * @param boolean $onlySpawnWhenMessageAvailable
277276 * @param boolean $isMassagesAvailableInTheQueue
278277 * @param int $shellBackgroundExpects
278+ * @param boolean $globalOnlySpawnWhenMessageAvailable
279+ * @param int $getOnlySpawnWhenMessageAvailableCallCount
279280 * @dataProvider runBasedOnOnlySpawnWhenMessageAvailableConsumerConfigurationDataProvider
280281 */
281282 public function testRunBasedOnOnlySpawnWhenMessageAvailableConsumerConfiguration (
282283 $ onlySpawnWhenMessageAvailable ,
283284 $ isMassagesAvailableInTheQueue ,
284- $ shellBackgroundExpects
285+ $ shellBackgroundExpects ,
286+ $ globalOnlySpawnWhenMessageAvailable ,
287+ $ getOnlySpawnWhenMessageAvailableCallCount
285288 ) {
286289 $ consumerName = 'consumerName ' ;
287290 $ connectionName = 'connectionName ' ;
288291 $ queueName = 'queueName ' ;
289- $ this ->deploymentConfigMock ->expects ($ this ->exactly (3 ))
292+ $ this ->deploymentConfigMock ->expects ($ this ->exactly (4 ))
290293 ->method ('get ' )
291294 ->willReturnMap (
292295 [
293296 ['cron_consumers_runner/cron_run ' , true , true ],
294297 ['cron_consumers_runner/max_messages ' , 10000 , 1000 ],
295298 ['cron_consumers_runner/consumers ' , [], []],
299+ ['queue/only_spawn_when_message_available ' , 0 , $ globalOnlySpawnWhenMessageAvailable ],
296300 ]
297301 );
298302
299303 /** @var ConsumerConfigInterface|MockObject $firstCunsumer */
300304 $ consumer = $ this ->getMockBuilder (ConsumerConfigItemInterface::class)
301305 ->getMockForAbstractClass ();
302- $ consumer ->expects ($ this ->any ())
303- ->method ('getName ' )
304- ->willReturn ($ consumerName );
306+ $ consumer ->method ('getName ' )->willReturn ($ consumerName );
305307 $ consumer ->expects ($ this ->once ())
306308 ->method ('getConnection ' )
307309 ->willReturn ($ connectionName );
308- $ consumer ->expects ($ this ->any ())
309- ->method ('getQueue ' )
310- ->willReturn ($ queueName );
311- $ consumer ->expects ($ this ->once ())
310+ $ consumer ->method ('getQueue ' )->willReturn ($ queueName );
311+ $ consumer ->expects ($ this ->exactly ($ getOnlySpawnWhenMessageAvailableCallCount ))
312312 ->method ('getOnlySpawnWhenMessageAvailable ' )
313313 ->willReturn ($ onlySpawnWhenMessageAvailable );
314314 $ this ->consumerConfigMock ->expects ($ this ->once ())
@@ -342,24 +342,45 @@ public function runBasedOnOnlySpawnWhenMessageAvailableConsumerConfigurationData
342342 [
343343 'onlySpawnWhenMessageAvailable ' => true ,
344344 'isMassagesAvailableInTheQueue ' => true ,
345- 'shellBackgroundExpects ' => 1
345+ 'shellBackgroundExpects ' => 1 ,
346+ 'globalOnlySpawnWhenMessageAvailable ' => false ,
347+ 'getOnlySpawnWhenMessageAvailableCallCount ' => 1
346348 ],
347349 [
348350 'onlySpawnWhenMessageAvailable ' => true ,
349351 'isMassagesAvailableInTheQueue ' => false ,
350- 'shellBackgroundExpects ' => 0
352+ 'shellBackgroundExpects ' => 0 ,
353+ 'globalOnlySpawnWhenMessageAvailable ' => false ,
354+ 'getOnlySpawnWhenMessageAvailableCallCount ' => 1
351355 ],
352356 [
353357 'onlySpawnWhenMessageAvailable ' => false ,
354358 'isMassagesAvailableInTheQueue ' => true ,
355- 'shellBackgroundExpects ' => 1
359+ 'shellBackgroundExpects ' => 1 ,
360+ 'globalOnlySpawnWhenMessageAvailable ' => false ,
361+ 'getOnlySpawnWhenMessageAvailableCallCount ' => 1
356362 ],
357363 [
358364 'onlySpawnWhenMessageAvailable ' => false ,
359365 'isMassagesAvailableInTheQueue ' => false ,
360- 'shellBackgroundExpects ' => 1
366+ 'shellBackgroundExpects ' => 1 ,
367+ 'globalOnlySpawnWhenMessageAvailable ' => false ,
368+ 'getOnlySpawnWhenMessageAvailableCallCount ' => 1
369+ ],
370+ [
371+ 'onlySpawnWhenMessageAvailable ' => true ,
372+ 'isMassagesAvailableInTheQueue ' => true ,
373+ 'shellBackgroundExpects ' => 1 ,
374+ 'globalOnlySpawnWhenMessageAvailable ' => true ,
375+ 'getOnlySpawnWhenMessageAvailableCallCount ' => 0
376+ ],
377+ [
378+ 'onlySpawnWhenMessageAvailable ' => true ,
379+ 'isMassagesAvailableInTheQueue ' => true ,
380+ 'shellBackgroundExpects ' => 1 ,
381+ 'globalOnlySpawnWhenMessageAvailable ' => false ,
382+ 'getOnlySpawnWhenMessageAvailableCallCount ' => 1
361383 ],
362-
363384 ];
364385 }
365386}
0 commit comments