You are here

public function ExporterTest::testRenameConfig in Tome 8

@covers \Drupal\tome_sync\EventSubscriber\ConfigEventSubscriber::configRename @covers \Drupal\tome_sync\EventSubscriber\LanguageConfigEventSubscriber::configSave @covers \Drupal\tome_sync\EventSubscriber\LanguageConfigEventSubscriber::configDelete

File

modules/tome_sync/tests/src/Kernel/ExporterTest.php, line 176

Class

ExporterTest
Tests that the exporter works.

Namespace

Drupal\Tests\tome_sync\Kernel

Code

public function testRenameConfig() {

  /** @var \Drupal\Core\Config\StorageInterface $storage */
  $storage = \Drupal::service('config.storage.sync');
  $data = [
    'hello' => 'world',
  ];
  \Drupal::configFactory()
    ->getEditable('foo.bar')
    ->setData($data)
    ->save();
  $this
    ->assertEquals($data, $storage
    ->read('foo.bar'));
  $override_data = [
    'bonjour' => 'monde',
  ];

  /** @var \Drupal\language\Config\LanguageConfigFactoryOverrideInterface $config_factory_override */
  $config_factory_override = \Drupal::service('language.config_factory_override');
  $override = $config_factory_override
    ->getOverride('fr', 'foo.bar');
  $override
    ->setData($override_data)
    ->save();
  $collection = $storage
    ->createCollection($override
    ->getStorage()
    ->getCollectionName());
  $this
    ->assertEquals($override_data, $collection
    ->read('foo.bar'));
  \Drupal::configFactory()
    ->rename('foo.bar', 'bar.baz');
  $this
    ->assertEquals($data, $storage
    ->read('bar.baz'));
  $this
    ->assertFalse($storage
    ->exists('foo.bar'));

  // @todo Add test coverage when https://www.drupal.org/project/drupal/issues/2981444
  // is fixed.
  // $this->assertEquals($override_data, $collection->read('bar.baz'));
  $this
    ->assertFalse($collection
    ->exists('foo.bar'));
}