protected static function doSetConfig() { $file = Path::truePath(static::setConfigFile(), static::getProjectDir()); if (!file_exists($file)) { throw new ConfigException("Config file doesn't exist"); } $type = pathinfo($file, PATHINFO_EXTENSION); if ($type === "ini") { static::$config = parse_ini_file($file, true); static::$configFileType = "ini"; } elseif ($type === "json") { static::$config = json_decode(file_get_contents($file), true); static::$configFileType = "json"; } elseif ($type === 'yml') { static::$config = Yaml::parse(file_get_contents($file)); static::$configFileType = "yaml"; } else { throw new ConfigException("Unknown config file format"); } if (!static::$config) { throw new ConfigException("Unable to parse {$type} file: {$file}"); } static::$config = ArrayCollection::createRecursive(static::$config); }
public function test_get_abs_path_from_config() { $expected = Path::truePath("../../testConfig.yml", __DIR__); $this->assertEquals($expected, IniConfig::getYamlFile()); }
/** * @expectedException \GMO\Common\Exception\PathException * @expectedExceptionMessage Cannot move up another directory */ public function test_true_path_exception() { $this->assertEquals("dummy.txt", Path::truePath("../../dummy.txt", "herp")); }