Inheritance: extends Symfony\Component\EventDispatcher\Event, implements PhpSpecEvent
示例#1
0
 /**
  * Run the `beforeSpecification` hook.
  *
  * @param  \PhpSpec\Event\SpecificationEvent $event
  * @return void
  */
 public function beforeSpecification(SpecificationEvent $event)
 {
     $spec = $event->getSpecification();
     if ($spec->getClassReflection()->hasMethod('setLaravel')) {
         $this->laravel->refreshApplication();
     }
 }
 function it_refreshes_the_laravel_framework_before_spec_is_run(Laravel $laravel, SpecificationEvent $event, SpecificationNode $spec, ReflectionClass $refl)
 {
     $event->getSpecification()->shouldBeCalled()->willReturn($spec);
     $spec->getClassReflection()->shouldBeCalled()->willReturn($refl);
     $refl->hasMethod('setLaravel')->shouldBeCalled()->willReturn(true);
     $laravel->refreshApplication()->shouldBeCalled();
     $this->beforeSpecification($event);
 }
 /**
  * @param SpecificationEvent $sus
  * @param Params             $param
  * @param Reporter           $reporter
  */
 public function analyse(SpecificationEvent $sus, Params $param, Reporter $reporter)
 {
     $class = $sus->getSpecification()->getTitle();
     $this->sus = new ReflectionClass($class);
     $this->param = $param;
     $this->reporter = $reporter;
     foreach ($this->detections as $detection) {
         $detection->check($this->sus, $this->param, $this->reporter);
     }
 }
示例#4
0
 function it_aggregates_testcase_nodes_and_store_them_after_specification_run(SpecificationEvent $event)
 {
     $event->getTitle()->willReturn('specification title');
     $event->getTime()->willReturn(42);
     $this->setTestCaseNodes(array('<testcase name="example1" />', '<testcase name="example2" />', '<testcase name="example3" />'));
     $this->setExampleStatusCounts(array(ExampleEvent::FAILED => 1, ExampleEvent::BROKEN => 2, ExampleEvent::PENDING => 5, ExampleEvent::SKIPPED => 3));
     $this->afterSpecification($event);
     $this->getTestSuiteNodes()->shouldReturn(array('<testsuite name="specification title" time="42.000000" tests="3" failures="1" errors="2" skipped="8">' . "\n" . '<testcase name="example1" />' . "\n" . '<testcase name="example2" />' . "\n" . '<testcase name="example3" />' . "\n" . '</testsuite>'));
     $this->getTestCaseNodes()->shouldHaveCount(0);
     $this->getExampleStatusCounts()->shouldReturn(array(ExampleEvent::PASSED => 0, ExampleEvent::PENDING => 0, ExampleEvent::SKIPPED => 0, ExampleEvent::FAILED => 0, ExampleEvent::BROKEN => 0));
 }
 function it_should_analyse_the_number_of_methods_size(SpecificationEvent $specificationEvent, SpecificationNode $specificationNode, Params $params, Reporter $reporter)
 {
     $specificationEvent->getSpecification()->willReturn($specificationNode);
     $specificationNode->getTitle()->willReturn('Elfiggo\\Brobdingnagian\\Detector\\ClassSize');
     $this->shouldNotThrow('Elfiggo\\Brobdingnagian\\Exception\\TooManyMethodsDetected');
     $params->getClassSize()->willReturn(200);
     $params->getDependenciesLimit()->willReturn(2);
     $params->getNumberOfMethods()->willReturn(5);
     $params->getMethodSize()->willReturn(10);
     $params->getNumberOfInterfaces()->willReturn(2);
     $params->getNumberOfTraits()->willReturn(1);
     $this->analyse($specificationEvent, $params, $reporter);
 }
 public function beforeSpecification(SpecificationEvent $event)
 {
     $examplesToAdd = array();
     $parser = new Parser();
     foreach ($event->getSpecification()->getExamples() as $example) {
         $dataProviderMethod = $parser->getDataProvider($example->getFunctionReflection());
         if (null !== $dataProviderMethod) {
             if (!$example->getSpecification()->getClassReflection()->hasMethod($dataProviderMethod)) {
                 return false;
             }
             $subject = $example->getSpecification()->getClassReflection()->newInstance();
             $providedData = $example->getSpecification()->getClassReflection()->getMethod($dataProviderMethod)->invoke($subject);
             if (is_array($providedData)) {
                 foreach ($providedData as $i => $dataRow) {
                     $examplesToAdd[] = new ExampleNode($i + 1 . ') ' . $example->getTitle(), $example->getFunctionReflection());
                 }
             }
         }
     }
     foreach ($examplesToAdd as $example) {
         $event->getSpecification()->addExample($example);
     }
 }
示例#7
0
 /**
  * @param SpecificationEvent $specification
  */
 public function beforeSpecification(SpecificationEvent $specification)
 {
     $index = $this->index++;
     $name = $specification->getTitle();
     include __DIR__ . "/Html/Template/ReportSpecificationStarts.html";
 }
示例#8
0
 /**
  * {@inheritdoc}
  */
 public function afterSpecification(SpecificationEvent $event)
 {
     $this->testSuiteNodes[] = sprintf('<testsuite name="%s" time="%s" tests="%s" failures="%s" errors="%s" skipped="%s">' . "\n" . '%s' . "\n" . '</testsuite>', $event->getTitle(), $event->getTime(), count($this->testCaseNodes), $this->exampleStatusCounts[ExampleEvent::FAILED], $this->exampleStatusCounts[ExampleEvent::BROKEN], $this->exampleStatusCounts[ExampleEvent::PENDING], implode("\n", $this->testCaseNodes));
     $this->initTestCaseNodes();
 }
 public function afterSpecification(SpecificationEvent $event)
 {
     $this->getIO()->writeln($this->teamCityMessage('testSuiteFinished', array('name' => $event->getTitle())));
 }
示例#10
0
 /**
  * @param SpecificationEvent $event
  */
 public function beforeSpecification(SpecificationEvent $event)
 {
     $this->currentSpecificationTitle = $event->getSpecification()->getTitle();
 }
 public function afterSpecification(SpecificationEvent $event)
 {
     $this->safelyFreeProperties($event->getSpecification());
 }
示例#12
0
 function it_outputs_undefined_progress_on_afterexample_event(SpecificationEvent $specEvent, ExampleEvent $exampleEvent, ExampleNode $example, SpecificationNode $spec, IO $io, StatisticsCollector $stats)
 {
     $specEvent->getSpecification()->willReturn($spec);
     $exampleEvent->getExample()->willReturn($example);
     $example->getTitle()->willReturn('foobar');
     $exampleEvent->getResult()->willReturn(999);
     $spec->getTitle()->willReturn('spec1');
     $this->beforeSpecification($specEvent);
     $this->afterExample($exampleEvent);
     $expected = "not ok 1 - spec1: foobar\n  ---\n  message: 'The example result type was unknown to formatter'\n  severity: fail\n  ...";
     $io->writeln($expected)->shouldHaveBeenCalled();
 }
示例#13
0
 public function beforeSpecification(SpecificationEvent $event)
 {
     $this->getIO()->writeln(sprintf("\n      %s\n", $event->getSpecification()->getTitle()), 0);
 }
 /**
  * Run the `beforeSpecification` hook.
  *
  * @param  \PhpSpec\Event\SpecificationEvent $event
  * @return void
  */
 public function beforeSpecification(SpecificationEvent $event)
 {
     $spec = $event->getSpecification();
     $refl = $spec->getClassReflection();
 }
 public function afterSpecification(SpecificationEvent $event)
 {
     $this->logger->logSpecification($event->getTitle(), $event->getTime());
 }
 public function afterSpecification(SpecificationEvent $event)
 {
     $this->finished('Suite', $event->getSpecification()->getTitle());
 }
 public function afterSpecification(SpecificationEvent $event)
 {
     $node = $event->getSpecification();
     $resource = $node->getResource();
     $this->logger->logSpecification($resource->getSrcFilename(), $node->getTitle(), $node->getClassReflection()->name, $resource->getSrcClassname());
 }