/** * @return \Composer\Composer */ public function getComposer() { if ($this->composer === NULL) { try { $this->composer = Factory::create($this->io, NULL, FALSE); } catch (\InvalidArgumentException $e) { $this->io->writeError($e->getMessage()); exit(1); } catch (\Composer\Json\JsonValidationException $e) { $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors()); $message = $e->getMessage() . ':' . PHP_EOL . $errors; throw new \Composer\Json\JsonValidationException($message); } } return $this->composer; }
/** * {@inheritdoc} */ public function writeError($messages, $newline = true) { foreach ((array) $messages as $message) { if (preg_match(self::REGEX, $message, $matches)) { throw new \RuntimeException($matches[0]); } } parent::writeError($messages, $newline); }
public function testWriteError() { $inputMock = $this->getMock('Symfony\\Component\\Console\\Input\\InputInterface'); $outputMock = $this->getMock('Symfony\\Component\\Console\\Output\\ConsoleOutputInterface'); $outputMock->expects($this->once())->method('getErrorOutput')->willReturn($outputMock); $outputMock->expects($this->once())->method('write')->with($this->equalTo('some information about something'), $this->equalTo(false)); $helperMock = $this->getMock('Symfony\\Component\\Console\\Helper\\HelperSet'); $consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock); $consoleIO->writeError('some information about something', false); }