Exemple #1
0
 /**
  * @return array
  */
 public function run()
 {
     $reflection = new \ReflectionClass($this->parallelProcessRunner);
     $property = $reflection->getProperty('waitCollection');
     $property->setAccessible(true);
     $waitCollection = $property->getValue($this->parallelProcessRunner);
     $property->setAccessible(false);
     $this->getProgressBarHelper()->create($waitCollection->count());
     $result = $this->parallelProcessRunner->run();
     $this->getProgressBarHelper()->finish();
     return $result;
 }
 /**
  * @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()));
 }