Exemplo n.º 1
0
 public function run(\PHPSpec\Runner\Reporter $reporter)
 {
     if ($reporter instanceof Reporter && $reporter->checkFailFast()) {
         return;
     }
     if ($this->testTargetRepository->testsOnlySpecifiedMethods() && !$this->testTargetRepository->shouldTreatElementAsTest(get_class($this->getExampleGroup()), $this->getMethodName())) {
         return;
     }
     $reporter->exampleStarted($this);
     parent::run($reporter);
     $reporter->exampleFinished($this);
 }
 /**
  * @param \ReflectionClass $exampleGroupClass
  */
 public function addExampleGroup(\ReflectionClass $exampleGroupClass)
 {
     if ($this->testTargetRepository->testsOnlySpecifiedClasses()) {
         if (!$this->testTargetRepository->shouldTreatElementAsTest($exampleGroupClass->getName())) {
             return;
         }
     }
     $examples = array();
     foreach ($exampleGroupClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $exampleMethod) {
         /* @var $exampleMethod \ReflectionMethod */
         if (strtolower(substr($exampleMethod->getName(), 0, 2)) == 'it') {
             if ($this->testTargetRepository->testsOnlySpecifiedMethods()) {
                 if (!$this->testTargetRepository->shouldTreatElementAsTest($exampleGroupClass->getName(), $exampleMethod->getName())) {
                     continue;
                 }
             }
             $examples[] = $exampleMethod;
         }
     }
     if (count($examples) > 0) {
         $exampleGroup = $exampleGroupClass->newInstance();
         $this->exampleGroups[] = $exampleGroup;
         $this->examplesByGroup[get_class($exampleGroup)] = $examples;
     }
 }
 /**
  * @param \SimpleTestCase $testCase
  * @return integer
  * @since Method available since Release 2.11.1
  */
 public function countTestsInTestCase(\SimpleTestCase $testCase)
 {
     $tests = $this->getTestsInTestCase($testCase);
     $testCount = 0;
     if ($this->testTargetRepository->testsOnlySpecifiedMethods()) {
         foreach ($tests as $method) {
             if ($this->testTargetRepository->shouldTreatElementAsTest(get_class($testCase), $method)) {
                 ++$testCount;
             }
         }
     } elseif ($this->testTargetRepository->testsOnlySpecifiedClasses()) {
         if ($this->testTargetRepository->shouldTreatElementAsTest(get_class($testCase))) {
             $testCount = count($tests);
         }
     } else {
         $testCount = count($tests);
     }
     return $testCount;
 }
 /**
  * @param string $testCase
  * @param string $method
  * @return boolean
  */
 public function shouldInvoke($testCase, $method)
 {
     return $this->testTargetRepository->shouldTreatElementAsTest($testCase);
 }