/**
  * Makes sure that an exception is thrown if the path could not be
  * retrieved from any of the sources recognized by `Path::current()`.
  * This test will bypass the `getcwd()` method and remove all used
  * environment variables.
  */
 public function testGetCurrentError()
 {
     unset($_SERVER['PWD']);
     unset($_SERVER['CD']);
     $this->setExpectedException('Phine\\Path\\Exception\\PathException', 'The current working directory path could not be found.');
     Path::current(true);
 }
Example #2
0
 /**
  * Creates a new configuration loader.
  *
  * @param string $dir The configuration directory path.
  *
  * @return array The loader, configuration directory path, and supported
  *               file extensions.
  */
 private function createLoader($dir = null)
 {
     if (null === $dir || '.' === $dir) {
         $dir = Path::current();
     }
     $extensions = array();
     $locator = new FileLocator($dir);
     $loaders = array('\\KHerGe\\Box\\Config\\Loader\\JsonFileLoader' => null, '\\KHerGe\\Box\\Config\\Loader\\PhpFileLoader' => null, '\\KHerGe\\Box\\Config\\Loader\\YamlFileLoader' => null);
     /** @var AbstractFileLoader $loader */
     foreach ($loaders as $class => &$loader) {
         $loader = new $class($locator);
         $extensions = array_merge($extensions, $loader->getSupportedExtensions());
     }
     return array(new DelegatingLoader(new LoaderResolver($loaders)), $dir, $extensions);
 }