fix: Validate config only after the options have been set
To avoid an exception when default options are not valid but the new options are.
This commit is contained in:
parent
5456cb5506
commit
5e9768e0e7
2 changed files with 15 additions and 1 deletions
|
@ -135,7 +135,6 @@ class Config
|
|||
{
|
||||
$this->applyOptions($options);
|
||||
$this->getEnv();
|
||||
$this->validateOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -216,6 +215,7 @@ class Config
|
|||
if (is_file($file)) {
|
||||
$options = Yaml::parse(file_get_contents($file));
|
||||
self::$instance = new self($options);
|
||||
self::$instance->validateOptions();
|
||||
} else {
|
||||
throw new Exception("Can't find config file at ".$file);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,20 @@ class ConfigTest extends BaseTest
|
|||
$this->assertConfig($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the getInstance function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetInstanceFromScratch()
|
||||
{
|
||||
Config::destroyInstance();
|
||||
|
||||
$config = Config::getInstance();
|
||||
$this->assertEquals($config->convert, false);
|
||||
$this->assertConfig($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that a Config object is correctly instantiated.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue