diff --git a/src/FuzeWorks/ConfigORM/ConfigORM.php b/src/FuzeWorks/ConfigORM/ConfigORM.php index 8d90c6d..1005082 100644 --- a/src/FuzeWorks/ConfigORM/ConfigORM.php +++ b/src/FuzeWorks/ConfigORM/ConfigORM.php @@ -88,6 +88,10 @@ class ConfigORM extends ConfigORMAbstract */ public function commit(): bool { + // If config has a lock file, don't write + if (isset($this->cfg['lock'])) + throw new ConfigException("Could not write config file. $this->file is locked with the 'lock' key."); + // Write the changes if (is_writable($this->file)) { $config = var_export($this->cfg, true); diff --git a/test/config/TestConfigWithEnvironment/config.testconfigwithenvironment.php b/test/config/TestConfigWithEnvironment/config.testconfigwithenvironment.php new file mode 100644 index 0000000..c03d59e --- /dev/null +++ b/test/config/TestConfigWithEnvironment/config.testconfigwithenvironment.php @@ -0,0 +1,42 @@ + Core::getEnv('TESTKEY'), + 'otherKey' => Core::getEnv('OTHERKEY', 'somethingDefault') +); \ No newline at end of file diff --git a/test/core/core_configTest.php b/test/core/core_configTest.php index af52120..83003cb 100644 --- a/test/core/core_configTest.php +++ b/test/core/core_configTest.php @@ -190,4 +190,20 @@ class configTest extends CoreTestAbstract $this->assertEquals($config2->key, 'other_value'); } + /** + * @coversNothing + */ + public function testConfigWithEnvironmentVariables() + { + // First push the test variable + putenv('TESTKEY=Superb'); + + // Load the config + $config = $this->config->getConfig('testconfigwithenvironment', ['test'.DS.'config'.DS.'TestConfigWithEnvironment']); + + // Check values + $this->assertEquals('Superb', $config->get('testKey')); + $this->assertEquals('somethingDefault', $config->get('otherKey')); + } + }