/**
  * @test
  */
 public function shouldCreate6ProcessesGivingThemTheCorrectEnvParameters()
 {
     $queue = $this->getMock('Liuggio\\Fastest\\Queue\\QueueInterface');
     $queue->expects($this->exactly(6))->method('isEmpty')->willReturn(false);
     $queue->expects($this->exactly(6))->method('pop')->willReturn(new TestSuite('path'));
     $processes = $this->getMockBuilder('Liuggio\\Fastest\\Process\\Processes')->disableOriginalConstructor()->getMock();
     $processes->expects($this->any())->method('getIndexesOfCompletedChannel')->willReturn(range(1, 3));
     $processes->expects($this->any())->method('add')->willReturn(true);
     $processes->expects($this->any())->method('start')->willReturn(true);
     $factory = $this->getMockBuilder('Liuggio\\Fastest\\Process\\ProcessFactory')->disableOriginalConstructor()->getMock();
     $array = array(array(1, 1, true), array(2, 2, true), array(3, 3, true), array(1, 4, false), array(2, 5, false), array(3, 6, false));
     foreach ($array as $at => $expectation) {
         $factory->expects($this->at($at))->method('createAProcess')->with($this->anything(), $this->equalTo($expectation[0]), $this->equalTo($expectation[1]), $this->equalTo($expectation[2]))->willReturn(new Process('echo ', rand()));
     }
     $manager = new ProcessesManager($factory, 1);
     $this->assertTrue($manager->assertNProcessRunning($queue, $processes));
     $this->assertTrue($manager->assertNProcessRunning($queue, $processes));
 }
Beispiel #2
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @param QueueInterface $queue
  * @param ProcessesManager $processManager
  * @return array
  */
 private function doExecute(InputInterface $input, OutputInterface $output, QueueInterface $queue, ProcessesManager $processManager)
 {
     $processes = null;
     if ($this->isVerbose($output)) {
         $progressBar = new VerboseRenderer($queue->count(), $this->hasErrorSummary($input), $output, $processManager->getNumberOfProcessExecutedByTheBeforeCommand());
     } else {
         $progressBar = new ProgressBarRenderer($queue->count(), $this->hasErrorSummary($input), $output, $this->getHelper('progress'), $processManager->getNumberOfProcessExecutedByTheBeforeCommand());
     }
     $progressBar->renderHeader($queue);
     while ($processManager->assertNProcessRunning($queue, $processes)) {
         $progressBar->renderBody($queue, $processes);
     }
     /**
      * @var Processes $processes
      */
     $processes->cleanUP();
     //it is not getting called with -p1 after the last process otherwise
     $processes->wait(function () use($progressBar, $queue, $processes) {
         $progressBar->renderBody($queue, $processes);
     });
     $progressBar->renderFooter($queue, $processes);
     return $processes;
 }