function LanguageConfigOverrideImportTest::testConfigOverrideImportEvents

Same name in other branches
  1. 9 core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php \Drupal\Tests\language\Functional\LanguageConfigOverrideImportTest::testConfigOverrideImportEvents()
  2. 10 core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php \Drupal\Tests\language\Functional\LanguageConfigOverrideImportTest::testConfigOverrideImportEvents()
  3. 11.x 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 72

Class

LanguageConfigOverrideImportTest
Ensures the language config overrides can be synchronized.

Namespace

Drupal\Tests\language\Functional

Code

public function testConfigOverrideImportEvents() {
    // 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();
    \Drupal::service('router.builder')->rebuild();
    // 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->assertFalse($event_recorder);
    $this->drupalGet('fr');
    $this->assertText('FR default site name');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.