getTitle() public method

public getTitle ( ) : string
return string
Exemplo n.º 1
0
 function it_should_call_afterCurrentExample(ExampleEvent $example)
 {
     $currentExample = new CurrentExampleTracker();
     $currentExample->setCurrentExample(null);
     $example->getTitle()->willReturn(null);
     $this->afterCurrentExample($example);
     $example->getTitle()->shouldNotHaveBeenCalled();
 }
Exemplo n.º 2
0
 public function afterExample(ExampleEvent $event)
 {
     $type = $this->map[$event->getResult()];
     $this->addResult($type, $event->getSpecification(), $event->getTitle());
     if ($this->coverage) {
         $this->coverage->stop();
     }
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 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>'));
 }
Exemplo n.º 5
0
 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>'));
 }
 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);
 }
 /**
  * @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())));
 }
Exemplo n.º 8
0
 /**
  *
  * @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));
 }
Exemplo n.º 9
0
 /**
  * {@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;
 }
 function it_writes_a_pass_message_for_a_passing_example(Template $template, ExampleEvent $event)
 {
     $event->getTitle()->willReturn(self::EVENT_TITLE);
     $template->render(Template::DIR . '/Template/ReportPending.html', array('title' => self::EVENT_TITLE, 'pendingExamplesCount' => 1))->shouldBeCalled();
     $this->write();
 }
Exemplo n.º 11
0
 /**
  */
 public function write()
 {
     $this->template->render(Template::DIR . '/Template/ReportPending.html', array('title' => $this->event->getTitle(), 'pendingExamplesCount' => self::$pendingExamplesCount));
     self::$pendingExamplesCount++;
 }
Exemplo n.º 12
0
 /**
  *
  */
 public function write()
 {
     $this->template->render(Template::DIR . '/Template/ReportPass.html', array('title' => $this->event->getTitle()));
 }
Exemplo n.º 13
0
 /**
  *
  */
 public function write()
 {
     $this->template->render(Template::DIR . '/Template/ReportSkipped.html', array('title' => htmlentities(strip_tags($this->event->getTitle())), 'message' => htmlentities(strip_tags($this->event->getMessage()))));
 }
Exemplo n.º 14
0
 public function beforeCurrentExample(ExampleEvent $event)
 {
     $this->currentExample->setCurrentExample($event->getTitle());
 }
 public function afterExample(ExampleEvent $event)
 {
     $this->logger->logExample($event->getSpecification()->getTitle(), $event->getTitle(), $event->getTime());
 }