getExample() public method

public getExample ( )
Example #1
0
 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);
     $exception->cause = $event->getExample()->getFunction();
     $message = $this->presenter->presentException($exception, $this->io->isVerbose());
     if (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()->getFunction()->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()->getFunction()->getStartLine(), $event->getExample()->getTitle()));
         $this->io->writeln(sprintf('<broken>%s</broken>', lcfirst($message)), 6);
     }
     $this->io->writeln();
 }
Example #2
0
 protected function printException(ExampleEvent $event, $depth = null)
 {
     if (null === ($exception = $event->getException())) {
         return;
     }
     // TODO: add cause to exception interface
     $exception->cause = $event->getExample()->getFunction();
     $depth = $depth ?: $event->getExample()->getDepth() * 2 + 6;
     $message = $this->presenter->presentException($exception, $this->io->isVerbose());
     if (ExampleEvent::FAILED === $event->getResult()) {
         $this->io->writeln(sprintf('<failed>%s</failed>', lcfirst($message)), $depth);
     } else {
         $this->io->writeln(sprintf('<broken>%s</broken>', lcfirst($message)), $depth);
     }
 }