Exemple #1
0
 public function groupsForTest(\PHPUnit_Framework_Test $test)
 {
     $groups = [];
     if ($test instanceof ScenarioDriven) {
         $groups = $test->getScenario()->getGroups();
     }
     if ($test instanceof Reported) {
         $info = $test->getReportFields();
         if (isset($info['class'])) {
             $groups = array_merge($groups, \PHPUnit_Util_Test::getGroups($info['class'], $info['name']));
         }
         $filename = $info['file'];
     } else {
         $groups = array_merge($groups, \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false)));
         $filename = (new \ReflectionClass($test))->getFileName();
     }
     foreach ($this->testsInGroups as $group => $tests) {
         foreach ($tests as $testPattern) {
             if ($filename == $testPattern) {
                 $groups[] = $group;
             }
             if (strpos($filename . ':' . $test->getName(false), $testPattern) === 0) {
                 $groups[] = $group;
             }
         }
     }
     return array_unique($groups);
 }
Exemple #2
0
 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     $steps = [];
     $success = $this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED;
     if ($success) {
         $this->successful++;
     }
     if ($test instanceof ScenarioDriven) {
         $steps = $test->getScenario()->getSteps();
     }
     $this->timeTaken += $time;
     switch ($this->testStatus) {
         case \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE:
             $scenarioStatus = 'scenarioFailed';
             break;
         case \PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED:
             $scenarioStatus = 'scenarioSkipped';
             break;
         case \PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE:
             $scenarioStatus = 'scenarioIncomplete';
             break;
         case \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR:
             $scenarioStatus = 'scenarioFailed';
             break;
         default:
             $scenarioStatus = 'scenarioSuccess';
     }
     $stepsBuffer = '';
     $metaStep = null;
     $subStepsBuffer = '';
     foreach ($steps as $step) {
         /** @var $step Step  **/
         if ($step->getMetaStep()) {
             $subStepsBuffer .= $this->renderStep($step);
             $metaStep = $step->getMetaStep();
             continue;
         }
         if ($step->getMetaStep() != $metaStep) {
             $stepsBuffer .= $this->renderSubsteps($metaStep, $subStepsBuffer);
             $subStepsBuffer = '';
         }
         $metaStep = $step->getMetaStep();
         $stepsBuffer .= $this->renderStep($step);
     }
     if ($subStepsBuffer and $metaStep) {
         $stepsBuffer .= $this->renderSubsteps($metaStep, $subStepsBuffer);
     }
     $scenarioTemplate = new \Text_Template($this->templatePath . 'scenario.html');
     $failure = '';
     $name = Descriptor::getTestSignature($test);
     if (isset($this->failures[$name])) {
         $failTemplate = new \Text_Template($this->templatePath . 'fail.html');
         $failTemplate->setVar(['fail' => nl2br($this->failures[$name])]);
         $failure = $failTemplate->render();
     }
     $toggle = $stepsBuffer ? '<span class="toggle">+</span>' : '';
     $scenarioTemplate->setVar(['id' => ++$this->id, 'name' => ucfirst(Descriptor::getTestAsString($test)), 'scenarioStatus' => $scenarioStatus, 'steps' => $stepsBuffer, 'toggle' => $toggle, 'failure' => $failure, 'time' => round($time, 2)]);
     $this->scenarios .= $scenarioTemplate->render();
 }
Exemple #3
0
 /**
  * A test ended.
  *
  * @param  PHPUnit_Framework_Test $test
  * @param  float                  $time
  */
 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     if ($test instanceof PHPUnit_Extensions_Story_TestCase || $test instanceof PHPUnit_Extensions_Story_SeleniumTestCase) {
         if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
             $this->successful++;
             $success = TRUE;
         } else {
             $success = FALSE;
         }
         $this->onTest($this->currentTestMethodPrettified, $success, $test->getScenario()->getSteps());
     }
 }
 /**
  * A test ended.
  *
  * @param  \PHPUnit_Framework_Test $test
  * @param  float $time
  */
 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     $steps = [];
     $success = $this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED;
     if ($success) {
         $this->successful++;
     }
     if ($test instanceof ScenarioDriven) {
         $steps = $test->getScenario()->getSteps();
     }
     $this->onTest($test->toString(), $success, $steps, $time);
 }
Exemple #5
0
 public function startTest(\PHPUnit_Framework_Test $test)
 {
     $this->dispatcher->dispatch(Events::TEST_START, new TestEvent($test));
     if (!$test instanceof CodeceptionTestCase) {
         return;
     }
     try {
         $test->getScenario()->stopIfBlocked();
         $this->startedTests[] = spl_object_hash($test);
         $this->fire(Events::TEST_BEFORE, new TestEvent($test));
     } catch (\PHPUnit_Framework_IncompleteTestError $e) {
         $this->addIncompleteTest($test, $e, 0);
     } catch (\PHPUnit_Framework_SkippedTestError $e) {
         $this->addSkippedTest($test, $e, 0);
     }
 }
 /**
  * A test ended.
  *
  * @param  \PHPUnit_Framework_Test $test
  * @param  float                  $time
  */
 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     $steps = array();
     if ($this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
         $this->successful++;
         $success = TRUE;
         if ($test instanceof \Codeception\TestCase) {
             $steps = $test->getScenario()->getSteps();
         }
     } else {
         $success = FALSE;
         if ($test instanceof \Codeception\TestCase) {
             $steps = $test->getTrace();
         }
     }
     $this->onTest($test->toString(), $success, $steps, $time);
 }