/** * @param string $text * @param array $templateVars */ public function render($text, array $templateVars = array()) { if (file_exists($text)) { $text = file_get_contents($text); } $templateKeys = $this->extractKeys($templateVars); $output = str_replace($templateKeys, array_values($templateVars), $text); $this->io->write($output); }
/** * @param ExampleEvent $event */ protected function printException(ExampleEvent $event) { if (null === ($exception = $event->getException())) { return; } $title = str_replace('\\', DIRECTORY_SEPARATOR, $event->getSpecification()->getTitle()); $title = str_pad($title, 50, ' ', STR_PAD_RIGHT); $message = $this->presenter->presentException($exception, $this->io->isVerbose()); if ($exception instanceof PendingException) { $this->io->writeln(sprintf('<pending-bg>%s</pending-bg>', $title)); $this->io->writeln(sprintf('<lineno>%4d</lineno> <pending>- %s</pending>', $event->getExample()->getFunctionReflection()->getStartLine(), $event->getExample()->getTitle())); $this->io->writeln(sprintf('<pending>%s</pending>', lcfirst($message)), 6); } elseif (ExampleEvent::FAILED === $event->getResult()) { $this->io->writeln(sprintf('<failed-bg>%s</failed-bg>', $title)); $this->io->writeln(sprintf('<lineno>%4d</lineno> <failed>✘ %s</failed>', $event->getExample()->getFunctionReflection()->getStartLine(), $event->getExample()->getTitle())); $this->io->writeln(sprintf('<failed>%s</failed>', lcfirst($message)), 6); } else { $this->io->writeln(sprintf('<broken-bg>%s</broken-bg>', $title)); $this->io->writeln(sprintf('<lineno>%4d</lineno> <broken>! %s</broken>', $event->getExample()->getFunctionReflection()->getStartLine(), $event->getExample()->getTitle())); $this->io->writeln(sprintf('<broken>%s</broken>', lcfirst($message)), 6); } $this->io->writeln(); }