/** * {@inheritdoc} */ public function execute(InputInterface $input, OutputInterface $output) { $result = null; $maxProcessesAmount = max(1, $input->getOption(self::OPTION_PARALLEL_PROCESS)); $locator = $input->getArgument('paths'); if ($maxProcessesAmount > 1) { $this->outputPrinter->init($output); $this->processFactory->init($this->inputDefinition, $input); $this->featureRunner->setMaxParallelProcess($maxProcessesAmount); $result = 0; foreach ($this->featureExtractor->extract($locator) as $featureNode) { $result = max($result, $this->featureRunner->run($featureNode)); } } return $result; }
/** * @param bool $error * @param array $expected * * @see OutputPrinter::afterStop * * @dataProvider providerAfterStep */ public function testAfterStop($error, array $expected) { $output = $this->getMock(ConsoleOutput::class, ['writeln']); foreach ($expected as $index => $line) { $output->expects($this->at($index))->method('writeln')->with($line); } $output->expects($this->exactly(count($expected)))->method('writeln'); $process = $this->getMock(ScenarioProcess::class, ['withError', 'getOutput', 'getErrorOutput'], [], '', false); $process->expects($this->once())->method('withError')->willReturn($error); $process->expects($this->once())->method('getOutput')->willReturn('output'); if ($error) { $process->expects($this->once())->method('getErrorOutput')->willReturn('error.output'); } else { $process->expects($this->never())->method('getErrorOutput'); } $event = $this->getMock(ProcessEvent::class, null, [$process]); /** @var OutputInterface $output */ /** @var ProcessEvent $event */ $printer = new OutputPrinter(); $printer->init($output); $printer->afterStop($event); }