Exemplo n.º 1
0
 /**
  * Loads a configuration file from a path.
  *
  * If the path does not exist, an empty configuration file is returned.
  *
  * @param string $path       The path to the configuration file.
  * @param Config $baseConfig The configuration that the loaded configuration
  *                           will inherit its values from.
  *
  * @return ConfigFile The loaded configuration file.
  *
  * @throws InvalidConfigException If the file contains invalid configuration.
  */
 public function loadConfigFile($path, Config $baseConfig = null)
 {
     try {
         // Don't use file_exists() to decouple from the file system
         return $this->reader->readConfigFile($path, $baseConfig);
     } catch (FileNotFoundException $e) {
         return new ConfigFile($path, $baseConfig);
     }
 }
 public function testLoadConfigFileWithBaseConfigCreatesNewIfNotFound()
 {
     $baseConfig = new Config();
     $this->reader->expects($this->once())->method('readConfigFile')->with('/path', $baseConfig)->will($this->throwException(new FileNotFoundException()));
     $this->assertEquals(new ConfigFile('/path', $baseConfig), $this->storage->loadConfigFile('/path', $baseConfig));
 }