PHPUnit_Util_DeprecatedFeature_Logger::log PHP Method

log() public static method

If it is run via a TestRunner and the test extends PHPUnit_Framework_TestCase, then this will inject the result into the test runner for display, if not, it will throw the notice to STDERR.
public static log ( string $message, integer | boolean $backtraceDepth = 2 )
$message string
$backtraceDepth integer | boolean
    public static function log($message, $backtraceDepth = 2)
    {
        if ($backtraceDepth !== FALSE) {
            $trace = debug_backtrace(FALSE);
            if (is_int($backtraceDepth)) {
                $traceItem = $trace[$backtraceDepth];
            }
            if (!isset($traceItem['file'])) {
                $reflectionClass = new ReflectionClass($traceItem['class']);
                $traceItem['file'] = $reflectionClass->getFileName();
            }
            if (!isset($traceItem['line']) && isset($traceItem['class']) && isset($traceItem['function'])) {
                if (!isset($reflectionClass)) {
                    $reflectionClass = new ReflectionClass($traceItem['class']);
                }
                $method = $reflectionClass->getMethod($traceItem['function']);
                $traceItem['line'] = '(between ' . $method->getStartLine() . ' and ' . $method->getEndLine() . ')';
            }
        }
        $deprecatedFeature = new PHPUnit_Util_DeprecatedFeature($message, $traceItem);
        if (self::$currentTest instanceof PHPUnit_Framework_TestCase) {
            $result = self::$currentTest->getTestResultObject();
            $result->addDeprecatedFeature($deprecatedFeature);
        } else {
            file_put_contents('php://stderr', $deprecatedFeature);
        }
    }

Usage Example

Beispiel #1
0
 /**
  * @return mixed
  * @throws RuntimeException
  */
 protected function runTest()
 {
     PHPUnit_Util_DeprecatedFeature_Logger::log('The functionality of PHPUnit_Extensions_OutputTestCase has been ' . 'merged into PHPUnit_Framework_TestCase. Please update your test ' . 'by extending PHPUnit_Framework_TestCase instead of ' . 'PHPUnit_Extensions_OutputTestCase.');
     return parent::runTest();
 }
All Usage Examples Of PHPUnit_Util_DeprecatedFeature_Logger::log