本文整理汇总了PHP中PHPUnit_Framework_Test::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Test::toString方法的具体用法?PHP PHPUnit_Framework_Test::toString怎么用?PHP PHPUnit_Framework_Test::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_Test
的用法示例。
在下文中一共展示了PHPUnit_Framework_Test::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: endTest
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);
}
示例2: startTest
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);
}
示例3: __construct
/**
* 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;
}
示例4: endTest
/**
* 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);
}
示例5: getTestName
/**
* @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;
}
示例6: endTest
/**
* 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);
}
示例7: describe
/**
* @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));
}
}
}
示例8: startTest
public function startTest(PHPUnit_Framework_Test $test)
{
$this->current['name'] = $test->getName(FALSE);
$this->current['description'] = $test->toString();
$this->current['result'] = 'passed';
}
示例9: doAddFault
/**
* 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);
}
示例10: addFailure
/**
* 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]++;
}
}
}
示例11: addFailure
/**
* 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);
}
示例12: startTest
public function startTest(PHPUnit_Framework_Test $test)
{
$this->currentTest = $test;
if (YTestOptions::$progress) {
YTestLogger::say("Test '" . $test->toString() . "' started.\n");
}
}
示例13: addFailureOrError
/**
* @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);
}
示例14: getTestException
/**
* 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];
}
}
}
}
示例15: toString
/**
* Returns a short description of the failure.
*
* @return string
*/
public function toString()
{
return sprintf('%s: %s', $this->failedTest->toString(), $this->thrownException->getMessage());
}