예제 #1
0
 /**
  * @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->getPresenter()->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);
         $this->io->writeln();
     } elseif ($exception instanceof SkippingException) {
         if ($this->io->isVerbose()) {
             $this->io->writeln(sprintf('<skipped-bg>%s</skipped-bg>', $title));
             $this->io->writeln(sprintf('<lineno>%4d</lineno>  <skipped>? %s</skipped>', $event->getExample()->getFunctionReflection()->getStartLine(), $event->getExample()->getTitle()));
             $this->io->writeln(sprintf('<skipped>%s</skipped>', lcfirst($message)), 6);
             $this->io->writeln();
         }
     } 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);
         $this->io->writeln();
     } 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();
     }
 }
예제 #2
0
 /**
  * @param ExampleEvent $event
  * @param string $type
  */
 protected function printSpecificException(ExampleEvent $event, $type)
 {
     $title = str_replace('\\', DIRECTORY_SEPARATOR, $event->getSpecification()->getTitle());
     $message = $this->getPresenter()->presentException($event->getException(), $this->io->isVerbose());
     foreach (explode("\n", wordwrap($title, $this->io->getBlockWidth(), "\n", true)) as $line) {
         $this->io->writeln(sprintf('<%s-bg>%s</%s-bg>', $type, str_pad($line, $this->io->getBlockWidth()), $type));
     }
     $this->io->writeln(sprintf('<lineno>%4d</lineno>  <%s>- %s</%s>', $event->getExample()->getFunctionReflection()->getStartLine(), $type, $event->getExample()->getTitle(), $type));
     $this->io->writeln(sprintf('<%s>%s</%s>', $type, lcfirst($message), $type), 6);
     $this->io->writeln();
 }
 function it_should_provide_extra_output_in_verbose_mode(\PHP_CodeCoverage $coverage, \PHP_CodeCoverage_Report_HTML $html, SuiteEvent $event, IO $io)
 {
     $reports = array('html' => $html);
     $this->beConstructedWith($coverage, $reports);
     $this->setOptions(array('format' => 'html', 'output' => array('html' => 'coverage')));
     $io->isVerbose()->willReturn(true);
     $this->setIO($io);
     $io->writeln('')->shouldBeCalled();
     $io->writeln('Generating code coverage report in html format ...')->shouldBeCalled();
     $this->afterSuite($event);
 }