public function ConfigEventsTest::testConfigRenameEvent in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Config/ConfigEventsTest.php \Drupal\KernelTests\Core\Config\ConfigEventsTest::testConfigRenameEvent()
- 9 core/tests/Drupal/KernelTests/Core/Config/ConfigEventsTest.php \Drupal\KernelTests\Core\Config\ConfigEventsTest::testConfigRenameEvent()
Tests configuration rename event that is fired from the ConfigFactory.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigEventsTest.php, line 58
Class
- ConfigEventsTest
- Tests events fired on configuration objects.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testConfigRenameEvent() {
$name = 'config_events_test.test';
$new_name = 'config_events_test.test_rename';
$GLOBALS['config'][$name] = [
'key' => 'overridden',
];
$GLOBALS['config'][$new_name] = [
'key' => 'new overridden',
];
$config = $this
->config($name);
$config
->set('key', 'initial')
->save();
$event = \Drupal::state()
->get('config_events_test.event', []);
$this
->assertSame(ConfigEvents::SAVE, $event['event_name']);
$this
->assertSame([
'key' => 'initial',
], $event['current_config_data']);
// Override applies when getting runtime config.
$this
->assertEquals($GLOBALS['config'][$name], \Drupal::config($name)
->get());
\Drupal::configFactory()
->rename($name, $new_name);
$event = \Drupal::state()
->get('config_events_test.event', []);
$this
->assertSame(ConfigEvents::RENAME, $event['event_name']);
$this
->assertSame([
'key' => 'new overridden',
], $event['current_config_data']);
$this
->assertSame([
'key' => 'initial',
], $event['raw_config_data']);
$this
->assertSame([
'key' => 'new overridden',
], $event['original_config_data']);
}