Beispiel #1
0
 public function testErrorStacking()
 {
     try {
         $handler = ErrorHandler::register();
         $handler->screamAt(E_USER_WARNING);
         $logger = $this->getMock('Psr\\Log\\LoggerInterface');
         $logger->expects($this->exactly(2))->method('log')->withConsecutive(array($this->equalTo(LogLevel::WARNING), $this->equalTo('Dummy log')), array($this->equalTo(LogLevel::DEBUG), $this->equalTo('Silenced warning')));
         $handler->setDefaultLogger($logger, array(E_USER_WARNING => LogLevel::WARNING));
         ErrorHandler::stackErrors();
         @trigger_error('Silenced warning', E_USER_WARNING);
         $logger->log(LogLevel::WARNING, 'Dummy log');
         ErrorHandler::unstackErrors();
         restore_error_handler();
         restore_exception_handler();
     } catch (\Exception $e) {
         restore_error_handler();
         restore_exception_handler();
         throw $e;
     }
 }