Пример #1
0
 public function testPsr0ClassLoader()
 {
     $loader = new Psr0ClassLoader();
     $loader->addNamespace('Universal\\ClassLoader', 'src');
     $loader->addNamespace('Universal', 'src');
     $classPath = $loader->resolveClass('Universal\\ClassLoader\\Psr0ClassLoader');
     $this->assertNotNull($classPath);
     $this->assertFileExists($classPath);
 }
 public function testChainedClassLoader()
 {
     $psr0 = new Psr0ClassLoader();
     $psr0->addNamespace('Universal\\ClassLoader', 'src');
     $psr4 = new Psr4ClassLoader();
     $psr4->addPrefix('MyBar\\', 'tests/fixtures/class_loader/psr4/simple/');
     $loader = new ChainedClassLoader([$psr0, $psr4]);
     $classPath = $loader->resolveClass('MyBar\\Foo');
     $this->assertEquals('tests/fixtures/class_loader/psr4/simple/Foo.php', $classPath);
     $this->assertNotNull($classPath);
     $this->assertFileExists($classPath);
     $classPath = $loader->resolveClass('Universal\\ClassLoader\\Psr0ClassLoader');
     $this->assertEquals('src/Universal/ClassLoader/Psr0ClassLoader.php', $classPath);
     $this->assertNotNull($classPath);
     $this->assertFileExists($classPath);
 }