public function testIsAbsolutePath()
 {
     $this->assertTrue(FajrUtils::isAbsolutePath('/'), 'Unix filesystem root is absolute');
     $this->assertTrue(FajrUtils::isAbsolutePath('/foo'), '/foo is absolute');
     $this->assertTrue(FajrUtils::isAbsolutePath('/foo/bar/'), '/foo/bar is absolute');
     $this->assertTrue(FajrUtils::isAbsolutePath('C:\\'), 'C:\\ is absolute');
     $this->assertTrue(FajrUtils::isAbsolutePath('\\\\servername\\folder'), '\\\\servername\\folder UNC path is absolute');
     $this->assertFalse(FajrUtils::isAbsolutePath('foo'), 'foo is relative');
     $this->assertFalse(FajrUtils::isAbsolutePath('./'), './ is relative');
 }
Example #2
0
 /**
  * Get a directory configuration path.
  *
  * If a relative path is given in configuration, it is resolved
  * relative to the specified directory or project root directory
  * if no directory was specified
  *
  * @param string $key
  * @returns string absolute path for the directory specified in configuration
  *                 or null if this option was not specified and does not have
  *                 a default value
  * @see FajrConfig::$defaultOptions
  * @see FajrConfig::$directoriesRelativeTo
  * @see configuration.example.php
  */
 public static function getDirectory($key)
 {
     $dir = self::get($key);
     if ($dir === null) {
         return null;
     }
     if (FajrUtils::isAbsolutePath($dir)) {
         return $dir;
     }
     // default resolve relative
     $relativeTo = dirname(__FILE__);
     if (!empty(self::$directoriesRelativeTo[$key])) {
         $relativeTo = self::getDirectory(self::$directoriesRelativeTo[$key]);
     }
     return FajrUtils::joinPath($relativeTo, $dir);
 }