You are here

public function ImportStorageTransformerTest::testTransform in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Config/ImportStorageTransformerTest.php \Drupal\KernelTests\Core\Config\ImportStorageTransformerTest::testTransform()
  2. 9 core/tests/Drupal/KernelTests/Core/Config/ImportStorageTransformerTest.php \Drupal\KernelTests\Core\Config\ImportStorageTransformerTest::testTransform()

Tests the import transformation.

File

core/tests/Drupal/KernelTests/Core/Config/ImportStorageTransformerTest.php, line 38

Class

ImportStorageTransformerTest
Tests the import storage transformer.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testTransform() {

  // Get the raw system.site config and set it in the sync storage.
  $rawConfig = $this
    ->config('system.site')
    ->getRawData();
  $storage = new MemoryStorage();
  $this
    ->copyConfig($this->container
    ->get('config.storage'), $storage);
  $import = $this->container
    ->get('config.import_transformer')
    ->transform($storage);
  $config = $import
    ->read('system.site');

  // The test subscriber always adds "Arrr" to the current site name.
  $this
    ->assertEquals($rawConfig['name'] . ' Arrr', $config['name']);
  $this
    ->assertEquals($rawConfig['slogan'], $config['slogan']);

  // Update the site config in the storage to test a second transformation.
  $config['name'] = 'New name';
  $config['slogan'] = 'New slogan';
  $storage
    ->write('system.site', $config);
  $import = $this->container
    ->get('config.import_transformer')
    ->transform($storage);
  $config = $import
    ->read('system.site');

  // The test subscriber always adds "Arrr" to the current site name.
  $this
    ->assertEquals($rawConfig['name'] . ' Arrr', $config['name']);
  $this
    ->assertEquals('New slogan', $config['slogan']);
}