You are here

public function ErrorHandlerTest::testLegacyInterface in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/debug/Tests/ErrorHandlerTest.php \Symfony\Component\Debug\Tests\ErrorHandlerTest::testLegacyInterface()

@group legacy

File

vendor/symfony/debug/Tests/ErrorHandlerTest.php, line 465

Class

ErrorHandlerTest
ErrorHandlerTest.

Namespace

Symfony\Component\Debug\Tests

Code

public function testLegacyInterface() {
  try {
    $handler = ErrorHandler::register(0);
    $this
      ->assertFalse($handler
      ->handle(0, 'foo', 'foo.php', 12, array()));
    restore_error_handler();
    restore_exception_handler();
    $logger = $this
      ->getMock('Psr\\Log\\LoggerInterface');
    $that = $this;
    $logArgCheck = function ($level, $message, $context) use ($that) {
      $that
        ->assertEquals('Undefined variable: undefVar', $message);
      $that
        ->assertArrayHasKey('type', $context);
      $that
        ->assertEquals($context['type'], E_NOTICE);
    };
    $logger
      ->expects($this
      ->once())
      ->method('log')
      ->will($this
      ->returnCallback($logArgCheck));
    $handler = ErrorHandler::register(E_NOTICE);
    @$handler
      ->setLogger($logger, 'scream');
    unset($undefVar);
    @$undefVar++;
    restore_error_handler();
    restore_exception_handler();
  } catch (\Exception $e) {
    restore_error_handler();
    restore_exception_handler();
    throw $e;
  }
}