1 config.test | public ConfigurationTest::testReadWriteClearConfig() |
Tests that a config setting can be written, read and deleted.
File
- core/
modules/ config/ tests/ config.test, line 18 - Tests for Configuration module.
Class
- ConfigurationTest
- Tests reading and writing file contents.
Code
public function testReadWriteClearConfig() {
// Long-hand setting, getting and deleting.
$config = config('foo.bar');
$config->set('foo', 'bar');
$config->save();
$this->assertEqual('bar', config('foo.bar')->get('foo'), 'Content retrieved from written config data using Config classes.');
$config->clear('foo');
$config->save();
$this->assertNull(config('foo.bar')->get('foo'), 'Deleted config data cannot be retrieved using Config classes.');
// Short-hand setting, getting and deleting.
config_set('foo.bar', 'foo', 'baz');
$this->assertEqual('baz', config_get('foo.bar', 'foo'), 'Content retrieved from written config data using short cut functions.');
config_clear('foo.bar', 'foo');
$this->assertNull(config_get('foo.bar', 'foo'), 'Deleted config data cannot be retrieved using shortcut functions.');
}