You are here

public function ConfigIgnoreTest::testValidateForceImporting in Config Ignore 8.2

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/ConfigIgnoreTest.php \Drupal\Tests\config_ignore\Functional\ConfigIgnoreTest::testValidateForceImporting()

Verify Force Import syntax is working.

This test makes sure we avoid regression issues.

File

tests/src/Functional/ConfigIgnoreTest.php, line 122

Class

ConfigIgnoreTest
Test functionality of config_ignore module.

Namespace

Drupal\Tests\config_ignore\Functional

Code

public function testValidateForceImporting() {

  // 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 the system.site:name to be (force-) imported upon config import.
  $settings = [
    IgnoreFilter::FORCE_EXCLUSION_PREFIX . 'system.site',
  ];
  $this
    ->config('config_ignore.settings')
    ->set('ignored_config_entities', $settings)
    ->save();
  $this
    ->doExport();

  // Change the site name, perform an import and see if the site name remains
  // the same, as it should.
  $this
    ->config('system.site')
    ->set('name', 'Changed title')
    ->save();
  $this
    ->doImport();
  $this
    ->assertEquals('Test import', $this
    ->config('system.site')
    ->get('name'));
}