You are here

public function ExampleStorageKernelTest::testExampleImport in Config Filter 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/ExampleStorageKernelTest.php \Drupal\Tests\config_filter\Kernel\ExampleStorageKernelTest::testExampleImport()

Example to test import.

File

tests/src/Kernel/ExampleStorageKernelTest.php, line 61

Class

ExampleStorageKernelTest
Example class to test the export and import with the test trait.

Namespace

Drupal\Tests\config_filter\Kernel

Code

public function testExampleImport() {

  // Write active config to file system as is.
  // This is not a config export, but for the sake of the test we set up
  // the sync storage to contain the same content as the active config.
  $this
    ->copyConfig($this
    ->getActiveStorage(), $this
    ->getSyncFileStorage());

  // Set up expectation for import.
  $expectedImport = new MemoryStorage();
  $this
    ->copyConfig($this
    ->getSyncFileStorage(), $expectedImport);

  // Simulate the filter.
  $system_site = $expectedImport
    ->read('system.site');

  // Importing means triggering the read filter methods.
  $system_site['name'] = 'Config Test Arrr';
  $expectedImport
    ->write('system.site', $system_site);

  // Do assertions.
  static::assertStorageEquals($expectedImport, $this
    ->getImportStorage());
}