예제 #1
0
 protected function initParallelProcessRunner()
 {
     $this->parallelProcessRunner = new ParallelProcessRunner();
     $this->parallelProcessRunner->setMaxParallelProcess(2);
     $this->parallelProcessRunner->setStatusCheckWait(15);
     $this->parallelProcessRunner->getEventDispatcher()->addSubscriber(new ParallelProcessSubscriber($this->getSymfonyStyle(), $this->getProgressBarHelper()));
 }
 /**
  * @param int   $maxParallelProcess
  * @param mixed $processes
  * @param array $expectedResult
  *
  * @dataProvider providerStop
  */
 public function testStop($maxParallelProcess, $processes, array $expectedResult)
 {
     $runner = new ParallelProcessRunner();
     $runner->setMaxParallelProcess($maxParallelProcess);
     $runner->add($processes);
     $runner->getEventDispatcher()->addListener(ParallelProcessRunnerEventType::PROCESS_STOP_AFTER, function (ProcessEvent $event) use($runner) {
         if ($event->getProcess()->getOutput() == 'stop') {
             $runner->stop();
         }
     });
     $this->assertEquals($expectedResult, $this->getOutputArray($runner->run()));
 }
 /**
  * @param int $maxParallelProcess
  *
  * @return $this
  */
 public function setMaxParallelProcess($maxParallelProcess)
 {
     $this->parallelProcessRunner->setMaxParallelProcess($maxParallelProcess);
     return $this;
 }