You are here

public function LanguageConfigOverrideImportTest::testConfigOverrideImportEvents in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/language/src/Tests/LanguageConfigOverrideImportTest.php \Drupal\language\Tests\LanguageConfigOverrideImportTest::testConfigOverrideImportEvents()

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

File

core/modules/language/src/Tests/LanguageConfigOverrideImportTest.php, line 67
Contains \Drupal\language\Tests\LanguageConfigOverrideImportTest.

Class

LanguageConfigOverrideImportTest
Ensures the language config overrides can be synchronized.

Namespace

Drupal\language\Tests

Code

public function testConfigOverrideImportEvents() {

  // Enable the config_events_test module so we can record events occurring.
  \Drupal::service('module_installer')
    ->install(array(
    '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', array(
    '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');
}