You are here

public function ErrorHandlerTest::testErrorStacking 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::testErrorStacking()

File

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

Class

ErrorHandlerTest
ErrorHandlerTest.

Namespace

Symfony\Component\Debug\Tests

Code

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