public function ClassLoaderTest::testClassExistsWithSilentAutoloader in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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
Namespace
Doctrine\Tests\CommonCode
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);
}