本文整理汇总了PHP中PhpSpec\Event\ExampleEvent::getResult方法的典型用法代码示例。如果您正苦于以下问题:PHP ExampleEvent::getResult方法的具体用法?PHP ExampleEvent::getResult怎么用?PHP ExampleEvent::getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpSpec\Event\ExampleEvent
的用法示例。
在下文中一共展示了ExampleEvent::getResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterExample
/**
*
* @param ExampleEvent $event
*
* @throws \PhpSpec\Exception\Example\StopOnFailureException
*/
public function afterExample(ExampleEvent $event)
{
if (!$this->io->isStopOnFailureEnabled()) {
return;
}
if ($event->getResult() === ExampleEvent::FAILED || $event->getResult() === ExampleEvent::BROKEN) {
throw new StopOnFailureException('Example failed', 0, null, $event->getResult());
}
}
示例2: afterExample
/**
* @param ExampleEvent $event
*
* @throws \PhpSpec\Exception\Example\StopOnFailureException
*/
public function afterExample(ExampleEvent $event)
{
if (!$this->input->hasOption('stop-on-failure') || !$this->input->getOption('stop-on-failure')) {
return;
}
if ($event->getResult() === ExampleEvent::FAILED || $event->getResult() === ExampleEvent::BROKEN) {
throw new StopOnFailureException('Example failed');
}
}
示例3: create
/**
* @param ExampleEvent $event
* @param PresenterInterface $presenter
*
* @return ReportFailedItem|ReportPassedItem|ReportPendingItem
*/
public function create(ExampleEvent $event, PresenterInterface $presenter = null)
{
switch ($event->getResult()) {
case ExampleEvent::PASSED:
return new ReportPassedItem($this->template, $event);
case ExampleEvent::PENDING:
return new ReportPendingItem($this->template, $event);
case ExampleEvent::FAILED:
case ExampleEvent::BROKEN:
return new ReportFailedItem($this->template, $event, $presenter);
default:
$this->invalidResultException($event->getResult());
}
}
示例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();
}
}
示例5: afterExample
/**
* @param ExampleEvent $event
*/
public function afterExample(ExampleEvent $event)
{
$this->examplesCount++;
$desc = sprintf(self::DESC, $this->currentSpecificationTitle, preg_replace('/^its? /', '', $event->getExample()->getTitle()));
switch ($event->getResult()) {
case ExampleEvent::PASSED:
$result = sprintf(self::OK, $this->examplesCount) . $desc;
break;
case ExampleEvent::PENDING:
$message = $this->getResultData($event, $event->getResult());
$result = sprintf(self::NOT_OK, $this->examplesCount) . $desc . $message;
break;
case ExampleEvent::SKIPPED:
$message = sprintf(self::SKIP, $this->getResultData($event));
$result = sprintf(self::OK, $this->examplesCount) . $desc . $message;
break;
case ExampleEvent::BROKEN:
case ExampleEvent::FAILED:
$message = $this->getResultData($event, $event->getResult());
$result = sprintf(self::NOT_OK, $this->examplesCount) . $desc . "\n" . $message;
break;
default:
$message = $this->getResultData($event, self::UNDEFINED_RESULT);
$result = sprintf(self::NOT_OK, $this->examplesCount) . $desc . "\n" . $message;
}
$this->getIO()->writeln($result);
}
示例6: afterExample
/**
*
* @param ExampleEvent $event
*/
public function afterExample(ExampleEvent $event)
{
$io = $this->getIO();
$eventsCount = $this->getStatisticsCollector()->getEventsCount();
if ($eventsCount === 1) {
$io->writeln();
}
switch ($event->getResult()) {
case ExampleEvent::PASSED:
$io->write('<passed>.</passed>');
break;
case ExampleEvent::PENDING:
$io->write('<pending>P</pending>');
break;
case ExampleEvent::SKIPPED:
$io->write('<skipped>S</skipped>');
break;
case ExampleEvent::FAILED:
$io->write('<failed>F</failed>');
break;
case ExampleEvent::BROKEN:
$io->write('<broken>B</broken>');
break;
}
if ($eventsCount % 50 === 0) {
$length = strlen((string) $this->examplesCount);
$format = sprintf(' %%%dd / %%%dd', $length, $length);
$io->write(sprintf($format, $eventsCount, $this->examplesCount));
if ($eventsCount !== $this->examplesCount) {
$io->writeLn();
}
}
}
示例7:
function it_outputs_monkey_when_example_is_pending(IO $io, ExampleEvent $event)
{
$event->getResult()->willReturn(ExampleEvent::PENDING);
$this->outputEmoji($event);
$io->write(mb_convert_encoding('🙉', 'UTF-8', 'HTML-ENTITIES'))->shouldHaveBeenCalled();
$io->write(' ')->shouldHaveBeenCalled();
}
示例8: afterExample
public function afterExample(ExampleEvent $event)
{
$type = $this->map[$event->getResult()];
$this->addResult($type, $event->getSpecification(), $event->getTitle());
if ($this->coverage) {
$this->coverage->stop();
}
}
示例9:
function it_should_creates_result_event(ExampleEvent $exampleEvent, SpecificationNode $specificationNode, CodeCoverageSession $coverageSession)
{
$exampleEvent->getResult()->shouldBeCalled()->willReturn(ExampleEvent::PASSED);
$specificationNode->getTitle()->shouldBeCalled()->willReturn('SomeSpesification');
$coverageSession->stop()->shouldBeCalled();
$this->afterExample($exampleEvent);
$this->getResults()->shouldHaveCount(1);
}
示例10: afterExample
public function afterExample(ExampleEvent $event)
{
$this->globalResult = max($this->globalResult, $event->getResult());
switch ($event->getResult()) {
case ExampleEvent::PASSED:
$this->passedEvents[] = $event;
break;
case ExampleEvent::PENDING:
$this->pendingEvents[] = $event;
break;
case ExampleEvent::FAILED:
$this->failedEvents[] = $event;
break;
case ExampleEvent::BROKEN:
$this->brokenEvents[] = $event;
break;
}
}
示例11:
function it_outputs_the_progress_every_50_examples(ExampleEvent $exampleEvent, SuiteEvent $suiteEvent, ConsoleIO $io, StatisticsCollector $stats)
{
$exampleEvent->getResult()->willReturn(ExampleEvent::PASSED);
$suiteEvent->getSuite()->willReturn(range(1, 100));
$stats->getEventsCount()->willReturn(50);
$this->beforeSuite($suiteEvent);
$this->afterExample($exampleEvent);
$io->write(' 50 / 100')->shouldHaveBeenCalled();
}
示例12: 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>'));
}
示例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>'));
}
示例14: outputEmoji
public function outputEmoji(ExampleEvent $event)
{
switch ($event->getResult()) {
case ExampleEvent::PASSED:
$this->io->write($this->encodeChar('😄'));
break;
case ExampleEvent::FAILED:
$this->io->write($this->encodeChar('💩'));
break;
case ExampleEvent::BROKEN:
$this->io->write($this->encodeChar('🔥'));
break;
case ExampleEvent::SKIPPED:
$this->io->write($this->encodeChar('🙈'));
break;
case ExampleEvent::PENDING:
$this->io->write($this->encodeChar('🙉'));
break;
}
$this->io->write(' ');
}
示例15: 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())));
}