function RecipeMultipleModulesConfigStorageTest::testCreateCollectionReadsFromSubdirectories

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

Tests createCollection() reads from collection subdirectories.

File

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

Class

RecipeMultipleModulesConfigStorageTest
Tests RecipeMultipleModulesConfigStorage.

Namespace

Drupal\Tests\Core\Recipe

Code

public function testCreateCollectionReadsFromSubdirectories() : void {
  // Add a collection subdirectory to the system module.
  vfsStream::create([
    'modules' => [
      'system' => [
        'config' => [
          'install' => [
            'system.image.yml' => Yaml::dump([
              'toolkit' => 'gd',
            ]),
            'language' => [
              'fr' => [
                'system.site.yml' => Yaml::dump([
                  'name' => 'Site FR',
                ]),
              ],
            ],
          ],
        ],
      ],
    ],
  ]);
  $storage = RecipeMultipleModulesConfigStorage::createFromModuleList([
    'system',
    'user',
  ], $this->extensionList);
  $frStorage = $storage->createCollection('language.fr');
  $this->assertSame('language.fr', $frStorage->getCollectionName());
  $this->assertTrue($frStorage->exists('system.site'));
  $this->assertSame([
    'name' => 'Site FR',
  ], $frStorage->read('system.site'));
  // The default collection config should not be visible.
  $this->assertFalse($frStorage->exists('system.image'));
  $this->assertTrue($storage->exists('system.image'));
}

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