lithium\test\Unit::_handleException PHP Метод

_handleException() защищенный Метод

Normalizes Exception objects and PHP error data into a single array format then the error data is logged to the test results.
См. также: lithium\test\Unit::_reportException()
protected _handleException ( mixed $exception, integer $lineFlag = null ) : void
$exception mixed An `Exception` object instance, or an array containing the following keys: `'message'`, `'file'`, `'line'`, `'trace'` (in `debug_backtrace()` format) and optionally `'code'` (error code number) and `'context'` (an array of variables relevant to the scope of where the error occurred).
$lineFlag integer A flag used for determining the relevant scope of the call stack. Set to the line number where test methods are called.
Результат void
    protected function _handleException($exception, $lineFlag = null)
    {
        $data = $exception;
        if (is_object($exception)) {
            $data = array();
            foreach (array('message', 'file', 'line', 'trace') as $key) {
                $method = 'get' . ucfirst($key);
                $data[$key] = $exception->{$method}();
            }
            $ref = $exception->getTrace();
            $ref = $ref[0] + array('class' => null);
            if ($ref['class'] === __CLASS__ && $ref['function'] === 'skipIf') {
                return $this->_result('skip', $data);
            }
        }
        return $this->_reportException($data, $lineFlag);
    }

Usage Example

Пример #1
0
 public function handleException($exception, $lineFlag = null)
 {
     return parent::_handleException($exception, $lineFlag);
 }