/** * @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); }