PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Testing » PHPUnit » Bug #5295

php warning in PHPUnit_TestCase::fail

Details

Submitted2005-09-05 00:46 UTC
Fromgiunta dot gaetano at sea-aeroportimilano dot it
StatusClosed
PackagePHPUnit
PHP Version4.3.11
OSany
Roadmaps(Not assigned)

Comments

[2005-09-05 00:46 UTC] giunta dot gaetano at sea-aeroportimilano dot it

Description:
------------
If fail() is called from user code, no line and file info will be available in debug_backtrace info, and a warning will be generated when tryng to recover them on line 217 of TestCase.php.

Patch:

/**
* Fails a test with the given message.
*
* @param string
* @access protected
*/
function fail($message = '') {
if (function_exists('debug_backtrace')) {
$trace = debug_backtrace();
if (array_key_exists('file', $trace[1]))
// fail called upon php error having been raised
$message = sprintf(
"%s in %s:%s",

$message,
$trace[1]['file'],
$trace[1]['line']
);

}

$this->_result->addFailure($this, $message);
$this->_failed = TRUE;
}