public function testShouldNotTerminateNonRunningProcessAtThePoolWhenTryingToTerminatePool() { $process1 = $this->getMock('Arara\\Process\\Process'); $process1->expects($this->any())->method('isRunning')->will($this->onConsecutiveCalls(true, false)); $process1->expects($this->never())->method('terminate'); $process2 = $this->getMock('Arara\\Process\\Process'); $process2->expects($this->any())->method('isRunning')->will($this->returnValue(true)); $process2->expects($this->once())->method('terminate'); $pool = new Pool(2, true); $pool->attach($process1); $pool->attach($process2); $pool->terminate(); }
<?php declare (ticks=1); require_once __DIR__ . '/../vendor/autoload.php'; use Arara\Process\Child; use Arara\Process\Control; use Arara\Process\Pool; use Arara\Test\TestAction; $control = new Control(); $pool = new Pool(10); $pool->start(); for ($index = 1; $index <= 9; $index++) { if (!$pool->isRunning()) { continue; } $action = new TestAction($index); $child = new Child($action, $control); $pool->attach($child); if (4 === $index) { $control->flush(0.5); $pool->terminate(); } }