Ejemplo n.º 1
0
 public function testConfigure()
 {
     $logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $userHandler = function () {
     };
     $listener = new DebugHandlersListener($userHandler, $logger);
     $xHandler = new ExceptionHandler();
     $eHandler = new ErrorHandler();
     $eHandler->setExceptionHandler(array($xHandler, 'handle'));
     $exception = null;
     set_error_handler(array($eHandler, 'handleError'));
     set_exception_handler(array($eHandler, 'handleException'));
     try {
         $listener->configure();
     } catch (\Exception $exception) {
     }
     restore_exception_handler();
     restore_error_handler();
     if (null !== $exception) {
         throw $exception;
     }
     $this->assertSame($userHandler, $xHandler->setHandler('var_dump'));
     $loggers = $eHandler->setLoggers(array());
     $this->assertArrayHasKey(E_DEPRECATED, $loggers);
     $this->assertSame(array($logger, LogLevel::INFO), $loggers[E_DEPRECATED]);
 }
 public function testConfigureForHttpKernelWithNoTerminateWithException()
 {
     $listener = new DebugHandlersListener(null);
     $eHandler = new ErrorHandler();
     $event = new KernelEvent($this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface'), Request::create('/'), HttpKernelInterface::MASTER_REQUEST);
     $exception = null;
     $h = set_exception_handler(array($eHandler, 'handleException'));
     try {
         $listener->configure($event);
     } catch (\Exception $exception) {
     }
     restore_exception_handler();
     if (null !== $exception) {
         throw $exception;
     }
     $this->assertNull($h);
 }