Ejemplo n.º 1
0
 public function testJoinPath()
 {
     $DS = DIRECTORY_SEPARATOR;
     $this->assertEquals(FajrUtils::joinPath($DS, $DS), $DS, '/,/');
     $this->assertEquals(FajrUtils::joinPath('foo', $DS), 'foo', 'foo,/');
     $this->assertEquals(FajrUtils::joinPath($DS, 'foo'), $DS . 'foo', '/,foo');
     $this->assertEquals(FajrUtils::joinPath($DS . 'foo' . $DS, 'bar'), $DS . 'foo' . $DS . 'bar', '/foo/,bar');
     $this->assertEquals(FajrUtils::joinPath('foo', 'bar'), 'foo' . $DS . 'bar', 'foo,bar');
     $this->assertEquals(FajrUtils::joinPath('foo' . $DS, $DS . 'bar'), 'foo' . $DS . 'bar', 'foo/,/bar');
     $this->assertEquals(FajrUtils::joinPath($DS . 'foo' . $DS, $DS . 'bar' . $DS), $DS . 'foo' . $DS . 'bar' . $DS, '/foo/,/bar/');
     $this->assertEquals(FajrUtils::joinPath('', ''), '', ',');
     $this->assertEquals(FajrUtils::joinPath($DS, 'foo', $DS, 'bar', $DS . 'baz'), $DS . 'foo' . $DS . 'bar' . $DS . 'baz', '/,foo,/,bar,/baz');
 }
Ejemplo n.º 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);
 }