You are here

public function LanguageConfigOverrideImportTest::testConfigOverrideImport 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::testConfigOverrideImport()

Tests that language can be enabled and overrides are created during a sync.

File

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

Class

LanguageConfigOverrideImportTest
Ensures the language config overrides can be synchronized.

Namespace

Drupal\language\Tests

Code

public function testConfigOverrideImport() {
  ConfigurableLanguage::createFromLangcode('fr')
    ->save();

  /* @var \Drupal\Core\Config\StorageInterface $sync */
  $sync = \Drupal::service('config.storage.sync');
  $this
    ->copyConfig(\Drupal::service('config.storage'), $sync);

  // Uninstall the language module and its dependencies so we can test
  // enabling the language module and creating overrides at the same time
  // during a configuration synchronization.
  \Drupal::service('module_installer')
    ->uninstall(array(
    'language',
  ));

  // Ensure that the current site has no overrides registered to the
  // ConfigFactory.
  $this
    ->rebuildContainer();

  /* @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',
  ));
  $override_sync
    ->write('system.maintenance', array(
    'message' => 'FR message: @site is currently under maintenance. We should be back shortly. Thank you for your patience',
  ));
  $this
    ->configImporter()
    ->import();
  $this
    ->rebuildContainer();
  \Drupal::service('router.builder')
    ->rebuild();
  $override = \Drupal::languageManager()
    ->getLanguageConfigOverride('fr', 'system.site');
  $this
    ->assertEqual('FR default site name', $override
    ->get('name'));
  $this
    ->drupalGet('fr');
  $this
    ->assertText('FR default site name');
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->drupalGet('admin/config/development/maintenance/translate/fr/edit');
  $this
    ->assertText('FR message: @site is currently under maintenance. We should be back shortly. Thank you for your patience');
}