当前位置: 首页>>代码示例>>PHP>>正文


PHP ExampleEvent::getException方法代码示例

本文整理汇总了PHP中PhpSpec\Event\ExampleEvent::getException方法的典型用法代码示例。如果您正苦于以下问题:PHP ExampleEvent::getException方法的具体用法?PHP ExampleEvent::getException怎么用?PHP ExampleEvent::getException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhpSpec\Event\ExampleEvent的用法示例。


在下文中一共展示了ExampleEvent::getException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 function it_does_not_prompt_to_generate_when_there_was_an_exception_of_the_wrong_type(IO $io, ExampleEvent $exampleEvent, SuiteEvent $suiteEvent, \InvalidArgumentException $otherException)
 {
     $exampleEvent->getException()->willReturn($otherException);
     $this->afterExample($exampleEvent);
     $this->afterSuite($suiteEvent);
     $io->askConfirmation(Argument::any())->shouldNotHaveBeenCalled();
 }
开发者ID:edwardricardo,项目名称:zenska,代码行数:7,代码来源:CollaboratorNotFoundListenerSpec.php

示例2: RuntimeException

 function it_does_not_prompt_when_wrong_exception_is_thrown(IO $io, ExampleEvent $event, SuiteEvent $suiteEvent)
 {
     $event->getException()->willReturn(new RuntimeException());
     $this->afterExample($event);
     $this->afterSuite($suiteEvent);
     $io->askConfirmation(Argument::any())->shouldNotHaveBeenCalled();
 }
开发者ID:qasem2rubik,项目名称:laravel,代码行数:7,代码来源:CollaboratorMethodNotFoundListenerSpec.php

示例3: afterExample

 public function afterExample(ExampleEvent $exampleEvent)
 {
     $exception = $exampleEvent->getException();
     if (!$exception instanceof NotEqualException) {
         return;
     }
     if ($exception->getActual() !== null) {
         return;
     }
     if (is_object($exception->getExpected()) || is_array($exception->getExpected()) || is_resource($exception->getExpected())) {
         return;
     }
     if (!$this->lastMethodCallEvent) {
         return;
     }
     $class = get_class($this->lastMethodCallEvent->getSubject());
     $method = $this->lastMethodCallEvent->getMethod();
     if (!$this->methodAnalyser->methodIsEmpty($class, $method)) {
         return;
     }
     $key = $class . '::' . $method;
     if (!array_key_exists($key, $this->nullMethods)) {
         $this->nullMethods[$key] = array('class' => $this->methodAnalyser->getMethodOwnerName($class, $method), 'method' => $method, 'expected' => array());
     }
     $this->nullMethods[$key]['expected'][] = $exception->getExpected();
 }
开发者ID:ProgrammingPeter,项目名称:nba-schedule-api,代码行数:26,代码来源:MethodReturnedNullListener.php

示例4: 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->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();
     }
 }
开发者ID:franzliedke,项目名称:phpspec,代码行数:35,代码来源:ConsoleFormatter.php

示例5:

 function it_identifies_a_resource_model_type(ExampleEvent $exampleEvent, ClassNotFoundException $exception, SuiteEvent $suiteEvent, $configGenerator)
 {
     $exampleEvent->getException()->willReturn($exception);
     $exception->getClassname()->willReturn('Vendor_Module_Model_Resource_Foo');
     $this->getClassNameAfterExample($exampleEvent);
     $this->createXmlAfterSuite($suiteEvent);
     $configGenerator->generateElement('resource_model', 'Vendor_Module')->shouldHavebeenCalled();
 }
开发者ID:kbulloch,项目名称:MageSpec_vm,代码行数:8,代码来源:ModuleUpdateListenerSpec.php

示例6: 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);
 }
开发者ID:edwardricardo,项目名称:zenska,代码行数:10,代码来源:ReportFailedItemSpec.php

示例7: afterExample

 /**
  * @param ExampleEvent $event
  */
 public function afterExample(ExampleEvent $event)
 {
     if (null === ($exception = $event->getException())) {
         return;
     }
     if (!$exception instanceof PhpSpecClassException && !$exception instanceof ProphecyClassException) {
         return;
     }
     $this->classes[$exception->getClassname()] = true;
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:13,代码来源:ClassNotFoundListener.php

示例8: afterExample

 public function afterExample(ExampleEvent $event)
 {
     if (null === ($exception = $event->getException())) {
         return;
     }
     if (!$exception instanceof MethodNotFoundException) {
         return;
     }
     $this->methods[get_class($exception->getSubject()) . '::' . $exception->getMethodName()] = $exception->getArguments();
 }
开发者ID:HarveyCheng,项目名称:myblog,代码行数:10,代码来源:MethodNotFoundListener.php

示例9: printSpecificException

 /**
  * @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();
 }
开发者ID:focuslife,项目名称:v0.1,代码行数:15,代码来源:ConsoleFormatter.php

示例10: ExceptionStub

 function it_stores_a_testcase_node_after_failed_example_run(ExampleEvent $event, SpecificationNode $specification, \ReflectionClass $refClass)
 {
     $event->getResult()->willReturn(ExampleEvent::FAILED);
     $event->getTitle()->willReturn('example title');
     $event->getTime()->willReturn(1337);
     $event->getException()->willReturn(new ExceptionStub('Something went wrong', 'Exception trace'));
     $event->getSpecification()->willReturn($specification);
     $specification->getClassReflection()->willReturn($refClass);
     $refClass->getName()->willReturn('Acme\\Foo\\Bar');
     $this->afterExample($event);
     $this->getTestCaseNodes()->shouldReturn(array('<testcase name="example title" time="1337" classname="Acme\\Foo\\Bar" status="failed">' . "\n" . '<failure type="spec\\PhpSpec\\Formatter\\ExceptionStub" message="Something went wrong" />' . "\n" . '<system-err>' . "\n" . '<![CDATA[' . "\n" . 'Exception trace' . "\n" . ']]>' . "\n" . '</system-err>' . "\n" . '</testcase>'));
 }
开发者ID:mawaha,项目名称:tracker,代码行数:12,代码来源:JUnitFormatterSpec.php

示例11: afterExample

 public function afterExample(ExampleEvent $event)
 {
     if (null === ($exception = $event->getException())) {
         return;
     }
     if (!$exception instanceof MethodNotFoundException) {
         return;
     }
     $classname = get_class($exception->getSubject());
     $methodName = $exception->getMethodName();
     $this->methods[$classname . '::' . $methodName] = $exception->getArguments();
     $this->checkIfMethodNameAllowed($methodName);
 }
开发者ID:phpspec,项目名称:phpspec,代码行数:13,代码来源:MethodNotFoundListener.php

示例12: afterExample

 /**
  * @param ExampleEvent $event
  */
 public function afterExample(ExampleEvent $event)
 {
     $io = $this->getIO();
     $output = ob_get_clean();
     if ($output) {
         $io->writeln($this->teamCityMessage("testStdOut", array("name" => $event->getTitle(), "out" => "Test Output\n>>>>>>>>>>>\n{$output}\n<<<<<<<<<<<\n")));
     }
     switch ($event->getResult()) {
         case ExampleEvent::PASSED:
             break;
         case ExampleEvent::PENDING:
             $io->writeln($this->teamCityMessage('testIgnored', array('name' => $event->getTitle(), 'details' => $event->getMessage())));
             break;
         case ExampleEvent::FAILED:
             $io->writeln($this->teamCityMessage('testFailed', array('name' => $event->getTitle(), 'message' => "Failed Test\n\n" . $event->getMessage(), 'details' => $event->getException()->getTraceAsString())));
             break;
         case ExampleEvent::BROKEN:
             $io->writeln($this->teamCityMessage('testFailed', array('name' => $event->getTitle(), 'message' => "Broken Test\n\n" . $event->getMessage(), 'details' => $event->getException()->getTraceAsString())));
             break;
     }
     $io->writeln($this->teamCityMessage('testFinished', array('name' => $event->getTitle())));
 }
开发者ID:ascii-soup,项目名称:phpspec-teamcity-formatter,代码行数:25,代码来源:TeamCityFormatter.php

示例13: SkippingException

 function it_stores_a_testcase_node_after_skipped_example_run(ExampleEvent $event, SpecificationNode $specification, \ReflectionClass $refClass)
 {
     $event->getResult()->willReturn(ExampleEvent::SKIPPED);
     $event->getTitle()->willReturn('example title');
     $event->getTime()->willReturn(1337);
     $event->getException()->willReturn(new SkippingException('zog zog'));
     $event->getSpecification()->willReturn($specification);
     $specification->getClassReflection()->willReturn($refClass);
     $refClass->getName()->willReturn('Acme\\Foo\\Bar');
     $this->afterExample($event);
     // skipped tag is escaped because a skipped tag is also registered in the console formatter
     $this->getTestCaseNodes()->shouldReturn(array('<testcase name="example title" time="1337.000000" classname="Acme\\Foo\\Bar" status="skipped">' . "\n" . '\\<skipped><![CDATA[ skipped: zog zog ]]>\\</skipped>' . "\n" . '</testcase>'));
 }
开发者ID:focuslife,项目名称:v0.1,代码行数:13,代码来源:JUnitFormatterSpec.php

示例14: getClassNameAfterExample

 public function getClassNameAfterExample(ExampleEvent $event)
 {
     if (null === ($exception = $event->getException())) {
         return;
     }
     if (!$exception instanceof PhpSpecClassException && !$exception instanceof ProphecyClassException) {
         return;
     }
     $className = $exception->getClassname();
     if (strlen($className)) {
         $parts = explode('_', $className);
         if (!isset($parts[0]) || !isset($parts[1])) {
             return;
         }
         $this->classNames[$className] = $parts[0] . '_' . $parts[1];
     }
 }
开发者ID:kbulloch,项目名称:MageSpec_vm,代码行数:17,代码来源:ModuleUpdateListener.php

示例15: PendingException

 function it_outputs_exceptions_for_failed_examples(SuiteEvent $event, ExampleEvent $pendingEvent, ConsoleIO $io, StatisticsCollector $stats, SpecificationNode $specification, ExampleNode $example)
 {
     $example->getLineNumber()->willReturn(37);
     $example->getTitle()->willReturn('it tests something');
     $pendingEvent->getException()->willReturn(new PendingException());
     $pendingEvent->getSpecification()->willReturn($specification);
     $pendingEvent->getExample()->willReturn($example);
     $stats->getEventsCount()->willReturn(1);
     $stats->getFailedEvents()->willReturn(array());
     $stats->getBrokenEvents()->willReturn(array());
     $stats->getPendingEvents()->willReturn(array($pendingEvent));
     $stats->getSkippedEvents()->willReturn(array());
     $stats->getTotalSpecs()->willReturn(1);
     $stats->getCountsHash()->willReturn(array('passed' => 0, 'pending' => 1, 'skipped' => 0, 'failed' => 0, 'broken' => 0));
     $this->afterSuite($event);
     $expected = '<lineno>  37</lineno>  <pending>- it tests something</pending>';
     $io->writeln($expected)->shouldHaveBeenCalled();
 }
开发者ID:phpspec,项目名称:phpspec,代码行数:18,代码来源:DotFormatterSpec.php


注:本文中的PhpSpec\Event\ExampleEvent::getException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。