本文整理汇总了PHP中PhpSpec\Event\ExampleEvent::getTime方法的典型用法代码示例。如果您正苦于以下问题:PHP ExampleEvent::getTime方法的具体用法?PHP ExampleEvent::getTime怎么用?PHP ExampleEvent::getTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpSpec\Event\ExampleEvent
的用法示例。
在下文中一共展示了ExampleEvent::getTime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printSlowTime
protected function printSlowTime(ExampleEvent $event)
{
$io = $this->getIO();
$ms = $event->getTime() * 1000;
if ($ms > 100) {
$io->write(sprintf(' <failed>(%sms)</failed>', round($ms)));
} elseif ($ms > 50) {
$io->write(sprintf(' <pending>(%sms)</pending>', round($ms)));
}
}
示例2: 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>'));
}
示例3: 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>'));
}
示例4: 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;
}
示例5: afterPassedExample
private function afterPassedExample(ExampleEvent $event)
{
$duration = $event->getTime() * 1000;
$this->finished('', $this->title($event), " duration='{$duration}'");
}
示例6: afterExample
public function afterExample(ExampleEvent $event)
{
$this->logger->logExample($event->getSpecification()->getTitle(), $event->getTitle(), $event->getTime());
}