function RecipeMultipleModulesConfigStorageTest::testReadSafety

Same name and namespace in other branches
  1. main core/tests/Drupal/Tests/Core/Recipe/RecipeMultipleModulesConfigStorageTest.php \Drupal\Tests\Core\Recipe\RecipeMultipleModulesConfigStorageTest::testReadSafety()

Tests read() safety: only read from the correct storage.

File

core/tests/Drupal/Tests/Core/Recipe/RecipeMultipleModulesConfigStorageTest.php, line 114

Class

RecipeMultipleModulesConfigStorageTest
Tests RecipeMultipleModulesConfigStorage.

Namespace

Drupal\Tests\Core\Recipe

Code

public function testReadSafety() : void {
  $storage = RecipeMultipleModulesConfigStorage::createFromModuleList([
    'user',
    'system',
  ], $this->extensionList);
  // The System module's version should be read.
  $this->assertSame([
    'name' => 'Site A',
  ], $storage->read('system.site'));
  $storage = RecipeMultipleModulesConfigStorage::createFromModuleList([
    'system',
    'user',
  ], $this->extensionList);
  // The System module's version should be read, regardless of the order of
  // the modules in the list.
  $this->assertSame([
    'name' => 'Site A',
  ], $storage->read('system.site'));
  $storage = RecipeMultipleModulesConfigStorage::createFromModuleList([
    'user',
  ], $this->extensionList);
  // The User module's version should never be read.
  $this->assertFalse($storage->read('system.site'));
}

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