@@ 269-294 (lines=26) @@ | ||
266 | $this->assertTrue($hit); |
|
267 | } |
|
268 | ||
269 | public function testOnSuccessSetterIsCalledOnSuccessfulProcess() |
|
270 | { |
|
271 | $process = Mockery::mock(Process::class); |
|
272 | $process->shouldReceive('stop'); |
|
273 | $process->shouldReceive('isStarted')->andReturn(true); |
|
274 | $process->shouldReceive('isRunning')->andReturn(false); |
|
275 | $process->shouldReceive('start')->atLeast()->once(); |
|
276 | $process->shouldReceive('isSuccessful')->once()->andReturn(true); |
|
277 | ||
278 | $hit = false; |
|
279 | ||
280 | $pool = new Pool(); |
|
281 | $this->assertSame( |
|
282 | $pool, |
|
283 | $pool->setOnSuccess(function ($proc) use ($process, &$hit) { |
|
284 | $this->assertEquals($proc, $process); |
|
285 | $hit = true; |
|
286 | }) |
|
287 | ); |
|
288 | ||
289 | $pool->add($process); |
|
290 | ||
291 | $pool->run(0); |
|
292 | ||
293 | $this->assertTrue($hit); |
|
294 | } |
|
295 | ||
296 | public function testOnFailureSetterIsCalledForErroredProcess() |
|
297 | { |
|
@@ 296-322 (lines=27) @@ | ||
293 | $this->assertTrue($hit); |
|
294 | } |
|
295 | ||
296 | public function testOnFailureSetterIsCalledForErroredProcess() |
|
297 | { |
|
298 | $process = Mockery::mock(Process::class); |
|
299 | $process->shouldReceive('stop'); |
|
300 | $process->shouldReceive('isStarted')->andReturn(true); |
|
301 | $process->shouldReceive('isRunning')->andReturn(false); |
|
302 | $process->shouldReceive('poll')->andReturn(false); |
|
303 | $process->shouldReceive('start')->atLeast()->once(); |
|
304 | $process->shouldReceive('isSuccessful')->once()->andReturn(false); |
|
305 | ||
306 | $hit = false; |
|
307 | ||
308 | $pool = new Pool(); |
|
309 | $this->assertSame( |
|
310 | $pool, |
|
311 | $pool->setOnFailure(function ($proc) use ($process, &$hit) { |
|
312 | $this->assertEquals($proc, $process); |
|
313 | $hit = true; |
|
314 | }) |
|
315 | ); |
|
316 | ||
317 | $pool->add($process); |
|
318 | ||
319 | $pool->run(0); |
|
320 | ||
321 | $this->assertTrue($hit); |
|
322 | } |
|
323 | ||
324 | public function testOnProgressSetterIsCalledDuringProcessRun() |
|
325 | { |