ConfigModuleOverridesTest.php in Drupal 10
File
core/tests/Drupal/KernelTests/Core/Config/ConfigModuleOverridesTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Config;
use Drupal\KernelTests\KernelTestBase;
class ConfigModuleOverridesTest extends KernelTestBase {
protected static $modules = [
'system',
'config',
'config_override_test',
];
public function testSimpleModuleOverrides() {
$GLOBALS['config_test_run_module_overrides'] = TRUE;
$name = 'system.site';
$overridden_name = 'ZOMG overridden site name';
$non_overridden_name = 'ZOMG this name is on disk mkay';
$overridden_slogan = 'Yay for overrides!';
$non_overridden_slogan = 'Yay for defaults!';
$config_factory = $this->container
->get('config.factory');
$config_factory
->getEditable($name)
->set('name', $non_overridden_name)
->set('slogan', $non_overridden_slogan)
->save();
$this
->assertEquals($non_overridden_name, $config_factory
->get('system.site')
->getOriginal('name', FALSE));
$this
->assertEquals($non_overridden_slogan, $config_factory
->get('system.site')
->getOriginal('slogan', FALSE));
$this
->assertEquals($overridden_name, $config_factory
->get('system.site')
->get('name'));
$this
->assertEquals($overridden_slogan, $config_factory
->get('system.site')
->get('slogan'));
$config = $config_factory
->get('config_override_test.new');
$this
->assertTrue($config
->isNew(), 'The configuration object config_override_test.new is new');
$this
->assertSame('override', $config
->get('module'));
$this
->assertNull($config
->getOriginal('module', FALSE));
unset($GLOBALS['config_test_run_module_overrides']);
}
}