function ConfigEventsTest::testConfigRenameEvent in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/config/src/Tests/ConfigEventsTest.php \Drupal\config\Tests\ConfigEventsTest::testConfigRenameEvent()
Tests configuration rename event that is fired from the ConfigFactory.
File
- core/
modules/ config/ src/ Tests/ ConfigEventsTest.php, line 64 - Contains \Drupal\config\Tests\ConfigEventsTest.
Class
- ConfigEventsTest
- Tests events fired on configuration objects.
Namespace
Drupal\config\TestsCode
function testConfigRenameEvent() {
$name = 'config_events_test.test';
$new_name = 'config_events_test.test_rename';
$GLOBALS['config'][$name] = array(
'key' => 'overridden',
);
$GLOBALS['config'][$new_name] = array(
'key' => 'new overridden',
);
$config = $this
->config($name);
$config
->set('key', 'initial')
->save();
$event = \Drupal::state()
->get('config_events_test.event', array());
$this
->assertIdentical($event['event_name'], ConfigEvents::SAVE);
$this
->assertIdentical($event['current_config_data'], array(
'key' => 'initial',
));
// Override applies when getting runtime config.
$this
->assertEqual($GLOBALS['config'][$name], \Drupal::config($name)
->get());
\Drupal::configFactory()
->rename($name, $new_name);
$event = \Drupal::state()
->get('config_events_test.event', array());
$this
->assertIdentical($event['event_name'], ConfigEvents::RENAME);
$this
->assertIdentical($event['current_config_data'], array(
'key' => 'new overridden',
));
$this
->assertIdentical($event['raw_config_data'], array(
'key' => 'initial',
));
$this
->assertIdentical($event['original_config_data'], array(
'key' => 'new overridden',
));
}