You are here

public function LanguageConfigOverrideImportTest::testConfigOverrideImportEvents in Drupal 9

Same name and namespace in other branches
  1. 8 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()

Tests that configuration events are not fired during a sync of overrides.

File

core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php, line 71

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();

  // 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
    ->assertSession()
    ->pageTextContains('FR default site name');
}