You are here

public function ClassNotFoundFatalErrorHandlerTest::testHandleClassNotFound in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php \Symfony\Component\Debug\Tests\FatalErrorHandler\ClassNotFoundFatalErrorHandlerTest::testHandleClassNotFound()

@dataProvider provideClassNotFoundData

1 call to ClassNotFoundFatalErrorHandlerTest::testHandleClassNotFound()
ClassNotFoundFatalErrorHandlerTest::testLegacyHandleClassNotFound in vendor/symfony/debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php
@group legacy

File

vendor/symfony/debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php, line 45

Class

ClassNotFoundFatalErrorHandlerTest

Namespace

Symfony\Component\Debug\Tests\FatalErrorHandler

Code

public function testHandleClassNotFound($error, $translatedMessage, $autoloader = null) {
  if ($autoloader) {

    // Unregister all autoloaders to ensure the custom provided
    // autoloader is the only one to be used during the test run.
    $autoloaders = spl_autoload_functions();
    array_map('spl_autoload_unregister', $autoloaders);
    spl_autoload_register($autoloader);
  }
  $handler = new ClassNotFoundFatalErrorHandler();
  $exception = $handler
    ->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
  if ($autoloader) {
    spl_autoload_unregister($autoloader);
    array_map('spl_autoload_register', $autoloaders);
  }
  $this
    ->assertInstanceOf('Symfony\\Component\\Debug\\Exception\\ClassNotFoundException', $exception);
  $this
    ->assertSame($translatedMessage, $exception
    ->getMessage());
  $this
    ->assertSame($error['type'], $exception
    ->getSeverity());
  $this
    ->assertSame($error['file'], $exception
    ->getFile());
  $this
    ->assertSame($error['line'], $exception
    ->getLine());
}