You are here

public function DebugHandlersListenerTest::testConfigure in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Tests/EventListener/DebugHandlersListenerTest.php \Symfony\Component\HttpKernel\Tests\EventListener\DebugHandlersListenerTest::testConfigure()

File

vendor/symfony/http-kernel/Tests/EventListener/DebugHandlersListenerTest.php, line 34

Class

DebugHandlersListenerTest
DebugHandlersListenerTest.

Namespace

Symfony\Component\HttpKernel\Tests\EventListener

Code

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]);
}