You are here

public function ClassLoaderTest::testClassExistsWithSilentAutoloader in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest.php \Doctrine\Tests\Common\ClassLoaderTest::testClassExistsWithSilentAutoloader()

File

vendor/doctrine/common/tests/Doctrine/Tests/Common/ClassLoaderTest.php, line 46

Class

ClassLoaderTest

Namespace

Doctrine\Tests\Common

Code

public function testClassExistsWithSilentAutoloader() {
  $test = $this;
  $silentLoader = function ($className) use ($test) {
    $test
      ->assertSame('ClassLoaderTest\\ClassE', $className);
    require __DIR__ . '/ClassLoaderTest/ClassE.php';
  };
  $additionalLoader = function () use ($test) {
    $test
      ->fail('Should not call this loader, class was already loaded');
  };
  $this
    ->assertFalse(ClassLoader::classExists('ClassLoaderTest\\ClassE'));
  spl_autoload_register($silentLoader);
  spl_autoload_register($additionalLoader);
  $this
    ->assertTrue(ClassLoader::classExists('ClassLoaderTest\\ClassE'));
  spl_autoload_unregister($additionalLoader);
  spl_autoload_unregister($silentLoader);
}