function LanguageConfigOverrideImportTest::testConfigOverrideImportEvents
Same name in other branches
- 9 core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php \Drupal\Tests\language\Functional\LanguageConfigOverrideImportTest::testConfigOverrideImportEvents()
- 8.9.x core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php \Drupal\Tests\language\Functional\LanguageConfigOverrideImportTest::testConfigOverrideImportEvents()
- 10 core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php \Drupal\Tests\language\Functional\LanguageConfigOverrideImportTest::testConfigOverrideImportEvents()
Tests that configuration events are not fired during a sync of overrides.
File
-
core/
modules/ language/ tests/ src/ Functional/ LanguageConfigOverrideImportTest.php, line 73
Class
- LanguageConfigOverrideImportTest
- Ensures the language config overrides can be synchronized.
Namespace
Drupal\Tests\language\FunctionalCode
public function testConfigOverrideImportEvents() : void {
// Enable the config_events_test module so we can record events occurring.
\Drupal::service('module_installer')->install([
'config_events_test',
]);
$this->rebuildContainer();
ConfigurableLanguage::createFromLangcode('fr')->save();
/** @var \Drupal\Core\Config\StorageInterface $sync */
$sync = \Drupal::service('config.storage.sync');
$this->copyConfig(\Drupal::service('config.storage'), $sync);
/** @var \Drupal\Core\Config\StorageInterface $override_sync */
$override_sync = $sync->createCollection('language.fr');
// Create some overrides in sync.
$override_sync->write('system.site', [
'name' => 'FR default site name',
]);
\Drupal::state()->set('config_events_test.event', FALSE);
$this->configImporter()
->import();
$this->rebuildContainer();
// Test that no config save event has been fired during the import because
// language configuration overrides do not fire events.
$event_recorder = \Drupal::state()->get('config_events_test.event', FALSE);
$this->assertSame([
'event_name' => ConfigCollectionEvents::SAVE_IN_COLLECTION,
'current_config_data' => [
'name' => 'FR default site name',
],
'original_config_data' => [],
'raw_config_data' => [
'name' => 'FR default site name',
],
], $event_recorder);
$this->drupalGet('fr');
$this->assertSession()
->pageTextContains('FR default site name');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.