Exemplo n.º 1
0
 public function run(ExampleGroup $exampleGroup, \PHPSpec\Runner\Reporter $reporter)
 {
     if ($reporter instanceof Reporter && $reporter->checkFailFast()) {
         return;
     }
     parent::run($exampleGroup, $reporter);
 }
Exemplo n.º 2
0
 /**
  * Runs the example
  * 
  * @param \PHPSpec\Runner\Reporter $reporter
  */
 public function run(Reporter $reporter)
 {
     try {
         $methodName = $this->_methodName;
         $startTime = microtime(true);
         call_user_func(array($this->_exampleGroup, 'before'));
         call_user_func(array($this->_exampleGroup, $methodName));
         call_user_func(array($this->_exampleGroup, 'after'));
         $endTime = microtime(true);
         $this->_executionTime = $endTime - $startTime;
         if (class_exists('Mockery')) {
             \Mockery::close();
         }
     } catch (Failure $failure) {
         $reporter->addFailure($this, $failure);
         return;
     } catch (Pending $pending) {
         $reporter->addPending($this, $pending);
         return;
     } catch (Error $error) {
         $reporter->addError($this, $error);
         return;
     } catch (\Exception $e) {
         $reporter->addException($this, new Exception($e));
         return;
     }
     $reporter->addPass($this);
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
 /**
  * Gets totals to print
  * 
  * @return string
  */
 protected function getTotals()
 {
     $failures = $this->_reporter->getFailures()->count();
     $errors = $this->_reporter->getErrors()->count();
     $pending = $this->_reporter->getPendingExamples()->count();
     $exceptions = $this->_reporter->getExceptions()->count();
     $passing = count($this->_reporter->getPassing());
     $total = $failures + $errors + $pending + $exceptions + $passing;
     if ($failures + $errors + $pending + $exceptions > 0) {
         $this->_errorOnExit = true;
     }
     $totals = "{$total} example" . ($total !== 1 ? "s" : "");
     if ($failures) {
         $plural = $failures !== 1 ? "s" : "";
         $totals .= ", {$failures} failure{$plural}";
     }
     if ($errors) {
         $plural = $errors !== 1 ? "s" : "";
         $totals .= ", {$errors} error{$plural}";
     }
     if ($exceptions) {
         $plural = $exceptions !== 1 ? "s" : "";
         $totals .= ", {$exceptions} exception{$plural}";
     }
     if ($pending) {
         $plural = $pending !== 1 ? "s" : "";
         $totals .= ", {$pending} pending{$plural}";
     }
     if ($failures || $errors || $exceptions) {
         $totals = $this->red($totals);
     } elseif ($pending) {
         $totals = $this->yellow($totals);
     } elseif ($passing) {
         $totals = $this->green($totals);
     }
     return $totals;
 }
Exemplo n.º 5
0
 /**
  * Sends a message to the reporter to show message
  */
 protected function showUsage()
 {
     $this->_reporter->setMessage($this->_runner->getUsage());
 }
Exemplo n.º 6
0
 /**
  * Checks if example group has finished, if it hasn't then it will notify
  * the reporter that it has
  */
 private function checkGroupFinished(ExampleGroup $exampleGroup, Reporter $reporter)
 {
     $groupName = get_class($exampleGroup);
     foreach ($this->getMethodNames($exampleGroup) as $method) {
         if ($this->methodIsAnExample($method) && $this->filterExample($method) && $this->groupHasntFinished($groupName)) {
             $reporter->exampleGroupFinished($exampleGroup);
             $this->_groupsFinished[] = $groupName;
         }
     }
 }