You are here

public function ConfigIgnoreTest::testValidateForceImportingWithWildcard in Config Ignore 8

Verify excluded configuration works with wildcards.

This test cover the scenario where a wildcard matches a specific configuration, but that's still imported due exclusion.

File

src/Tests/ConfigIgnoreTest.php, line 174

Class

ConfigIgnoreTest
Class ConfigIgnoreTest.

Namespace

Drupal\config_ignore\Tests

Code

public function testValidateForceImportingWithWildcard() {

  // Login with a user that has permission to import config.
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'import configuration',
  ]));

  // Set the site name to a known value that we later will try and overwrite.
  $this
    ->config('system.site')
    ->set('name', 'Test import')
    ->save();

  // Set system.* configs to be ignored and system.site:name to be (force-)
  // imported upon config import.
  $settings = [
    'system.' . ConfigImporterIgnore::INCLUDE_SUFFIX,
    ConfigImporterIgnore::FORCE_EXCLUSION_PREFIX . 'system.site',
  ];
  $this
    ->config('config_ignore.settings')
    ->set('ignored_config_entities', $settings)
    ->save();

  // Assemble a change that will try and override the current value.
  $config = $this
    ->config('system.site')
    ->set('name', 'Import has changed title');
  $edit = [
    'config_type' => 'system.simple',
    'config_name' => $config
      ->getName(),
    'import' => Yaml::encode($config
      ->get()),
  ];

  // Submit a new single item config, with the changes.
  $this
    ->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
  $this
    ->drupalPostForm(NULL, [], t('Confirm'));

  // Validate if the title from the imported config was imported.
  $this
    ->assertText('Import has changed title');
}