本文整理汇总了PHP中PhpSpec\Formatter\Presenter\PresenterInterface::presentException方法的典型用法代码示例。如果您正苦于以下问题:PHP PresenterInterface::presentException方法的具体用法?PHP PresenterInterface::presentException怎么用?PHP PresenterInterface::presentException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpSpec\Formatter\Presenter\PresenterInterface
的用法示例。
在下文中一共展示了PresenterInterface::presentException方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function it_writes_a_fail_message_for_a_failing_example(Template $template, ExampleEvent $event, Presenter $presenter)
{
$event->getTitle()->willReturn(self::EVENT_TITLE);
$event->getMessage()->willReturn(self::EVENT_MESSAGE);
$event->getBacktrace()->willReturn(self::$BACKTRACE);
$event->getException()->willReturn(new \Exception());
$template->render(Template::DIR . '/Template/ReportFailed.html', array('title' => self::EVENT_TITLE, 'message' => self::EVENT_MESSAGE, 'backtrace' => self::BACKTRACE, 'code' => self::CODE, 'index' => 1, 'specification' => 1))->shouldBeCalled();
$presenter->presentException(Argument::cetera())->willReturn(self::CODE);
$this->write(1);
}
示例2: printException
/**
* @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();
}
示例3: write
/**
*
* @param int $index
*/
public function write($index)
{
$code = $this->presenter->presentException($this->event->getException(), true);
$this->template->render(Template::DIR . '/Template/ReportFailed.html', array('title' => htmlentities(strip_tags($this->event->getTitle())), 'message' => htmlentities(strip_tags($this->event->getMessage())), 'backtrace' => $this->formatBacktrace(), 'code' => $code, 'index' => self::$failingExamplesCount++, 'specification' => $index));
}