mageekguy\atoum\includer::errorHandler PHP Method

errorHandler() public method

public errorHandler ( $error, $message, $file, $line, $context )
    public function errorHandler($error, $message, $file, $line, $context)
    {
        $errorReporting = $this->adapter->error_reporting();
        if ($errorReporting !== 0 && $errorReporting & $error) {
            foreach (array_reverse(debug_backtrace()) as $trace) {
                if (isset($trace['file']) === true && $trace['file'] === $this->path) {
                    $file = $this->path;
                    $line = $trace['line'];
                    break;
                }
            }
            $this->errors[] = array($error, $message, $file, $line, $context);
        }
        return true;
    }

Usage Example

コード例 #1
0
ファイル: includer.php プロジェクト: xihewang/atoum
 public function testErrorHandler()
 {
     $this->if($includer = new testedClass($adapter = new atoum\test\adapter()))->and($adapter->error_reporting = E_ALL)->then->boolean($includer->errorHandler($errno = E_NOTICE, $message = uniqid(), $file = uniqid(), $line = rand(1, PHP_INT_MAX), $context = array()))->isTrue()->array($includer->getErrors())->isEqualTo(array(array($errno, $message, $file, $line, $context)))->boolean($includer->errorHandler($otherErrno = E_WARNING, $otherMessage = uniqid(), $otherFile = uniqid(), $otherLine = rand(1, PHP_INT_MAX), $otherContext = array()))->isTrue()->array($includer->getErrors())->isEqualTo(array(array($errno, $message, $file, $line, $context), array($otherErrno, $otherMessage, $otherFile, $otherLine, $otherContext)))->if($includer->resetErrors())->then->boolean($includer->errorHandler(E_USER_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->array($includer->getErrors())->isNotEmpty()->if($includer->resetErrors())->then->boolean($includer->errorHandler(E_USER_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->array($includer->getErrors())->isNotEmpty()->if($includer->resetErrors())->then->boolean($includer->errorHandler(E_DEPRECATED, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->array($includer->getErrors())->isNotEmpty()->if($adapter->error_reporting = E_ALL & ~E_DEPRECATED)->and($includer->resetErrors())->then->boolean($includer->errorHandler(E_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->array($includer->getErrors())->isNotEmpty()->if($includer->resetErrors())->then->boolean($includer->errorHandler(E_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->array($includer->getErrors())->isNotEmpty()->if($includer->resetErrors())->then->boolean($includer->errorHandler(E_USER_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->array($includer->getErrors())->isNotEmpty()->if($includer->resetErrors())->then->boolean($includer->errorHandler(E_USER_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->array($includer->getErrors())->isNotEmpty()->if($includer->resetErrors())->then->boolean($includer->errorHandler(E_DEPRECATED, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->array($includer->getErrors())->isEmpty();
 }