class ConfigExportStorageTest

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigExportStorageTest.php \Drupal\KernelTests\Core\Config\ConfigExportStorageTest
  2. 10 core/tests/Drupal/KernelTests/Core/Config/ConfigExportStorageTest.php \Drupal\KernelTests\Core\Config\ConfigExportStorageTest
  3. 8.9.x core/tests/Drupal/KernelTests/Core/Config/ConfigExportStorageTest.php \Drupal\KernelTests\Core\Config\ConfigExportStorageTest

Tests configuration export storage.

@group config

Hierarchy

Expanded class hierarchy of ConfigExportStorageTest

File

core/tests/Drupal/KernelTests/Core/Config/ConfigExportStorageTest.php, line 12

Namespace

Drupal\KernelTests\Core\Config
View source
class ConfigExportStorageTest extends KernelTestBase {
  
  /**
   * Modules to enable.
   *
   * @var array
   */
  protected static $modules = [
    'system',
    'config_test',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->installConfig([
      'system',
      'config_test',
    ]);
  }
  
  /**
   * Tests configuration override.
   */
  public function testExportStorage() {
    /** @var \Drupal\Core\Config\StorageInterface $active */
    $active = $this->container
      ->get('config.storage');
    /** @var \Drupal\Core\Config\StorageInterface $export */
    $export = $this->container
      ->get('config.storage.export');
    // Test that the active and the export storage contain the same config.
    $this->assertNotEmpty($active->listAll());
    $this->assertEquals($active->listAll(), $export->listAll());
    foreach ($active->listAll() as $name) {
      $this->assertEquals($active->read($name), $export->read($name));
    }
    // Test that the export storage is read-only.
    $this->expectException(\BadMethodCallException::class);
    $export->deleteAll();
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.