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


PHP ExampleEvent::getSpecification方法代码示例

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


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

示例1: beforeExample

 public function beforeExample(ExampleEvent $event)
 {
     $specFilename = $event->getSpecification()->getClassReflection()->getFileName();
     $specClass = $event->getSpecification()->getClassReflection()->getName();
     $exampleName = $event->getExample()->getFunctionReflection()->getName();
     $this->getIO()->writeln($this->teamCityMessage('testStarted', array('name' => $event->getTitle(), 'captureStandardOutput' => 'false', 'locationHint' => "file://{$specFilename}::\\{$specClass}::{$exampleName}")));
     ob_start();
 }
开发者ID:ascii-soup,项目名称:phpspec-teamcity-formatter,代码行数:8,代码来源:TeamCityFormatter.php

示例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->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

示例3: afterExample

 public function afterExample(ExampleEvent $event)
 {
     $type = $this->map[$event->getResult()];
     $this->addResult($type, $event->getSpecification(), $event->getTitle());
     if ($this->coverage) {
         $this->coverage->stop();
     }
 }
开发者ID:phpguard,项目名称:plugin-phpspec,代码行数:8,代码来源:PhpGuardExtension.php

示例4: 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

示例5: 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

示例6: 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

示例7: let

 function let(SpecificationNode $specificationNode, ExampleEvent $exampleEvent, ServiceContainer $container, CodeCoverageSession $coverageSession)
 {
     $r = new \ReflectionClass(__CLASS__);
     $specificationNode->getClassReflection()->willReturn($r);
     $specificationNode->getTitle()->willReturn('Specification');
     $exampleEvent->getSpecification()->willReturn($specificationNode);
     $exampleEvent->getTitle()->willReturn('it should do something');
     $this->cwd = getcwd();
     chdir(sys_get_temp_dir());
     $container->get('coverage.session')->willReturn($coverageSession);
     $this->setCoverageRunner($coverageSession);
     $this->load($container);
 }
开发者ID:phpguard,项目名称:plugin-phpspec,代码行数:13,代码来源:PhpGuardExtensionSpec.php

示例8: 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

示例9: afterExample

 /**
  * {@inheritdoc}
  */
 public function afterExample(ExampleEvent $event)
 {
     $testCaseNode = sprintf('<testcase name="%s" time="%s" classname="%s" status="%s"', $event->getTitle(), $event->getTime(), $event->getSpecification()->getClassReflection()->getName(), $this->jUnitStatuses[$event->getResult()]);
     $this->exampleStatusCounts[$event->getResult()]++;
     if (in_array($event->getResult(), array(ExampleEvent::BROKEN, ExampleEvent::FAILED))) {
         $exception = $event->getException();
         $testCaseNode .= sprintf('>' . "\n" . '<%s type="%s" message="%s" />' . "\n" . '<system-err>' . "\n" . '<![CDATA[' . "\n" . '%s' . "\n" . ']]>' . "\n" . '</system-err>' . "\n" . '</testcase>', $this->resultTags[$event->getResult()], get_class($exception), htmlspecialchars($exception->getMessage()), $exception->getTraceAsString());
     } else {
         $testCaseNode .= ' />';
     }
     $this->testCaseNodes[] = $testCaseNode;
 }
开发者ID:mawaha,项目名称:tracker,代码行数:15,代码来源:JUnitFormatter.php

示例10: afterExample

 public function afterExample(ExampleEvent $event)
 {
     $this->logger->logExample($event->getSpecification()->getTitle(), $event->getTitle(), $event->getTime());
 }
开发者ID:padraic,项目名称:phpspec-extensions,代码行数:4,代码来源:TimeCollectorListener.php


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