public function testGetFallbackDirs()
 {
     $loader = new ClassLoader();
     $loader->addPrefix(null, __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures');
     $loader->addPrefix(null, __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures');
     $fallback_dirs = $loader->getFallbackDirs();
     $this->assertCount(2, $fallback_dirs);
 }
Exemplo n.º 2
0
 /**
  * Finds file to store a class.
  *
  * @param string $class
  *
  * @return string
  *
  * @throws ContextNotFoundException If class file could not be determined
  */
 private function findClassFile($class)
 {
     list($classpath, $classname) = $this->findClasspathAndClass($class);
     $classpath .= str_replace('_', DIRECTORY_SEPARATOR, $classname) . '.php';
     foreach ($this->autoloader->getPrefixes() as $prefix => $dirs) {
         if (0 === strpos($class, $prefix)) {
             return current($dirs) . DIRECTORY_SEPARATOR . $classpath;
         }
     }
     if ($dirs = $this->autoloader->getFallbackDirs()) {
         return current($dirs) . DIRECTORY_SEPARATOR . $classpath;
     }
     throw new ContextNotFoundException(sprintf('Could not find where to put "%s" class. Have you configured autoloader properly?', $class), $class);
 }