public function ConfigWithTranslationTest::testConfigExport in Config Ignore 8.3
Tests config export.
File
- tests/src/ Functional/ ConfigWithTranslationTest.php, line 101 
Class
- ConfigWithTranslationTest
- Tests config_ignore with translated configurations.
Namespace
Drupal\Tests\config_ignore\FunctionalCode
public function testConfigExport() {
  // Change configurations in the active store.
  $this
    ->config('user.settings')
    ->set('anonymous', 'Visitor')
    ->save();
  $this
    ->config('user.role.anonymous')
    ->set('label', 'Visitor')
    ->save();
  $this
    ->config('user.role.authenticated')
    ->set('label', 'Authenticated')
    ->set('weight', 2)
    ->set('is_admin', TRUE)
    ->save();
  // Change translations of user.role.anonymous and user.role.authenticated.
  $this
    ->translateConfig('user.role.anonymous', 'label', 'Vizitator', 'ro');
  $this
    ->translateConfig('user.role.authenticated', 'label', 'Logat', 'ro');
  // Export changes.
  $this
    ->drush('config:export', [], [
    'yes' => NULL,
  ]);
  // Check that user.settings changes were exported.
  $this
    ->assertExportedValue('user.settings', 'anonymous', 'Visitor');
  // Check that the main user.role.anonymous.yml file was not overridden.
  $this
    ->assertExportedValue('user.role.anonymous', 'label', 'Anonymous user');
  // Check that the translated version was not overridden.
  $this
    ->assertExportedValue('user.role.anonymous', 'label', 'Utilizator anonim', 'ro');
  // Check that user.role.authenticated changes were exported.
  $this
    ->assertExportedValue('user.role.authenticated', 'label', 'Authenticated');
  $this
    ->assertExportedValue('user.role.authenticated', 'weight', 1);
  $this
    ->assertExportedValue('user.role.authenticated', 'is_admin', FALSE);
  // Check that the translated version has been exported too.
  $this
    ->assertExportedValue('user.role.authenticated', 'label', 'Logat', 'ro');
  // Delete user.role.authenticated from sync storage in order to test again
  // when the destination is missed.
  $sync_storage = $this
    ->getSyncStorage();
  $sync_storage
    ->delete('user.role.authenticated');
  // Re-export changes.
  $this
    ->drush('config:export', [], [
    'yes' => NULL,
  ]);
  $data = $sync_storage
    ->read('user.role.authenticated');
  // Check that weight & is_admin keys were ignored on the new created config.
  $this
    ->assertArrayNotHasKey('weight', $data);
  $this
    ->assertArrayNotHasKey('is_admin', $data);
}