Exemple #1
0
 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     if ($test instanceof \Codeception\TestCase\Cept) {
         $this->currentTestCase->setAttribute('name', $test->toString());
     }
     return parent::endTest($test, $time);
 }
 public function startTest(PHPUnit_Framework_Test $test)
 {
     if ($this->_verbose) {
         echo date('Y-m-d H:i:s') . ': starting ' . $test->toString() . "\n\n";
     }
     if ($this->_getProgressBar()) {
         //erstellt sie beim ersten aufruf, nicht im kostruktor machen da sonst zu früh was rausgeschrieben wird
         $this->writeProgress('.');
     }
     return parent::startTest($test);
 }
Exemple #3
0
 /**
  * Constructs a TestFailure with the given test and exception.
  *
  * @param PHPUnit_Framework_Test $failedTest
  * @param Exception $thrownException
  */
 public function __construct(PHPUnit_Framework_Test $failedTest, Exception $thrownException)
 {
     if ($failedTest instanceof PHPUnit_Framework_SelfDescribing) {
         $this->testName = $failedTest->toString();
     } else {
         $this->testName = get_class($failedTest);
     }
     if (!$failedTest instanceof PHPUnit_Framework_TestCase || !$failedTest->isInIsolation()) {
         $this->failedTest = $failedTest;
     }
     $this->thrownException = $thrownException;
 }
 /**
  * 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);
 }
 /**
  * @param \PHPUnit_Framework_Test $test
  * @return string
  */
 protected function getTestName(\PHPUnit_Framework_Test $test)
 {
     if ($test instanceof \PHPUnit_Framework_TestCase) {
         $name = $test->getName();
     } elseif ($test instanceof \PHPUnit_Framework_TestSuite) {
         $name = $test->getName();
     } elseif ($test instanceof \PHPUnit_Framework_SelfDescribing) {
         $name = $test->toString();
     } else {
         $name = get_class($test);
     }
     return $name;
 }
 /**
  * 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);
 }
Exemple #7
0
 /**
  * @param  PHPUnit_Framework_Test $test
  * @param  bool                   $asString
  * @return mixed
  */
 public static function describe(PHPUnit_Framework_Test $test, $asString = true)
 {
     if ($asString) {
         if ($test instanceof PHPUnit_Framework_SelfDescribing) {
             return $test->toString();
         } else {
             return get_class($test);
         }
     } else {
         if ($test instanceof PHPUnit_Framework_TestCase) {
             return array(get_class($test), $test->getName());
         } elseif ($test instanceof PHPUnit_Framework_SelfDescribing) {
             return array('', $test->toString());
         } else {
             return array('', get_class($test));
         }
     }
 }
Exemple #8
0
 public function startTest(PHPUnit_Framework_Test $test)
 {
     $this->current['name'] = $test->getName(FALSE);
     $this->current['description'] = $test->toString();
     $this->current['result'] = 'passed';
 }
Exemple #9
0
 /**
  * Method which generalizes addError() and addFailure()
  *
  * @param PHPUnit_Framework_Test $test
  * @param Exception              $e
  * @param float                  $time
  * @param string                 $type
  */
 private function doAddFault(PHPUnit_Framework_Test $test, Exception $e, $time, $type)
 {
     if ($this->currentTestCase === null) {
         return;
     }
     if ($test instanceof PHPUnit_Framework_SelfDescribing) {
         $buffer = $test->toString() . "\n";
     } else {
         $buffer = '';
     }
     $buffer .= PHPUnit_Framework_TestFailure::exceptionToString($e) . "\n" . PHPUnit_Util_Filter::getFilteredStacktrace($e);
     $fault = $this->document->createElement($type, PHPUnit_Util_XML::prepareString($buffer));
     $fault->setAttribute('type', get_class($e));
     $this->currentTestCase->appendChild($fault);
 }
Exemple #10
0
 /**
  * A failure occurred.
  *
  * @param PHPUnit_Framework_Test                 $test
  * @param PHPUnit_Framework_AssertionFailedError $e
  * @param float                                  $time
  */
 public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
 {
     if ($this->currentTestCase !== null) {
         if (!$test instanceof PHPUnit_Framework_Warning) {
             if ($test instanceof PHPUnit_Framework_SelfDescribing) {
                 $buffer = $test->toString() . "\n";
             } else {
                 $buffer = '';
             }
             $buffer .= PHPUnit_Framework_TestFailure::exceptionToString($e) . "\n" . PHPUnit_Util_Filter::getFilteredStacktrace($e);
             $failure = $this->document->createElement('failure', PHPUnit_Util_XML::prepareString($buffer));
             $failure->setAttribute('type', get_class($e));
             $this->currentTestCase->appendChild($failure);
             $this->testSuiteFailures[$this->testSuiteLevel]++;
         }
     }
 }
Exemple #11
0
 /**
  * A failure occurred.
  *
  * @param PHPUnit_Framework_Test                 $test
  * @param PHPUnit_Framework_AssertionFailedError $e
  * @param float                                  $time
  */
 public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time)
 {
     $this->failures[$test->toString()] = $e->getMessage();
     parent::addFailure($test, $e, $time);
 }
Exemple #12
0
 public function startTest(PHPUnit_Framework_Test $test)
 {
     $this->currentTest = $test;
     if (YTestOptions::$progress) {
         YTestLogger::say("Test '" . $test->toString() . "' started.\n");
     }
 }
 /**
  * @param PHPUnit_Framework_Test $test
  * @param Exception              $e
  * @param float                  $time
  * @param string                 $failureOrError
  */
 protected function addFailureOrError(PHPUnit_Framework_Test $test, Exception $e, $time, $failureOrError)
 {
     if ($test instanceof PHPUnit_Framework_SelfDescribing) {
         $message = $test->toString() . "\n\n";
     } else {
         $message = '';
     }
     $message .= PHPUnit_Framework_TestFailure::exceptionToString($e) . "\n";
     $this->writeFailureOrError($message, $e, $failureOrError);
 }
 /**
  * Trys to get the original exception thrown by the test on failure/error 
  * to enable us to give a bit more detail about the failure/error
  * 
  * @access private
  * @param obj PHPUnit_Framework_Test, current test that is being run
  * @param obj PHPUnit_Framework_AssertationFailedError, PHPUnit error
  * @return array
  */
 private function getTestException(PHPUnit_Framework_Test $test, Exception $e)
 {
     // get the name of the testFile from the test
     $testName = preg_replace('/(.*)\\((.*[^)])\\)/', '\\2', $test->toString());
     $trace = $e->getTrace();
     // loop through the exception trace to find the original exception
     for ($i = 0; $i < count($trace); $i++) {
         if (array_key_exists('file', $trace[$i])) {
             if (stristr($trace[$i]['file'], $testName . '.php') != false) {
                 return $trace[$i];
             }
         }
         if (array_key_exists('file:protected', $trace[$i])) {
             if (stristr($trace[$i]['file:protected'], $testName . '.php') != false) {
                 return $trace[$i];
             }
         }
     }
 }
 /**
  * Returns a short description of the failure.
  *
  * @return string
  */
 public function toString()
 {
     return sprintf('%s: %s', $this->failedTest->toString(), $this->thrownException->getMessage());
 }
 public function startTest(PHPUnit_Framework_Test $test)
 {
     echo "\n" . date('Y-m-d H:i:s') . ': starting ' . $test->toString() . "\n";
     return parent::startTest($test);
 }
 public function startTest(PHPUnit_Framework_Test $test)
 {
     if ($test instanceof PHPUnit_Framework_Warning) {
         $pieces = explode('"', $test->getMessage());
         if (count($pieces) == 3) {
             $testName = $pieces[1];
             $shownTestName = "Warning (" . $testName . ")";
             print traceCommand("testStarted", "name", $shownTestName, "locationHint", "php_qn://" . $this->myfilename . "::::" . $testName);
             print traceCommand("testIgnored", "name", $shownTestName, "message", $test->getMessage());
             print traceCommand("testFinished", "name", $shownTestName, "duration", 0);
             return;
         }
     }
     print traceCommand("testStarted", "name", $test->getName(), "locationHint", "php_qn://" . $this->myfilename . "::" . $test->toString());
     flush();
 }
 /**
  * Get name for this test
  *
  * @param PHPUnit_Framework_Test $test
  * @return string
  */
 protected function descriptiveTestName(PHPUnit_Framework_Test $test)
 {
     if ($test instanceof PHPUnit_Framework_TestCase) {
         $name = $test->toString();
     } elseif (method_exists($test, 'getName')) {
         $name = $test->getName();
     } else {
         $name = get_class($test);
     }
     // the name of the test (without the suite name)
     return preg_replace('(\\(.*\\))', '', $name);
 }
 private function logError(\PHPUnit_Framework_Test $test, \Exception $e)
 {
     $this->lastFailure = $e->getMessage();
     $this->failures[$test->toString()] = $e->getMessage();
 }