You are here

public function ModuleConfigOverridesTest::testModuleOverrides in Config override 8

File

tests/Unit/ModuleConfigOverridesTest.php, line 19

Class

ModuleConfigOverridesTest
@coversDefaultClass \Drupal\config_override\ModuleConfigOverrides @group config_override

Namespace

Drupal\config_override\Tests\Unit

Code

public function testModuleOverrides() {
  $cache_backend = $this
    ->prophesize(CacheBackendInterface::class);
  $module_handler = $this
    ->prophesize(ModuleHandlerInterface::class);
  $extension_a = new Extension('vfs://drupal', 'module', 'modules/module_a/module_a.info.yml');
  $extension_b = new Extension('vfs://drupal', 'module', 'modules/module_b/module_b.info.yml');
  vfsStream::setup('drupal');
  vfsStream::create([
    'modules' => [
      'module_a' => [
        'config' => [
          'override' => [
            'system.site.yml' => Yaml::encode([
              'name' => 'Hey jude',
            ]),
          ],
        ],
      ],
      'module_b' => [
        'config' => [
          'override' => [
            'system.site.yml' => Yaml::encode([
              'slogan' => 'Muh',
            ]),
          ],
        ],
      ],
    ],
  ]);
  $module_handler
    ->getModuleList()
    ->willReturn([
    'module_a' => $extension_a,
    'module_b' => $extension_b,
  ]);
  $module_overrides = new ModuleConfigOverrides('vfs://drupal', $module_handler
    ->reveal(), $cache_backend
    ->reveal());
  $expected = [
    'system.site' => [
      'name' => 'Hey jude',
      'slogan' => 'Muh',
    ],
  ];
  $result = $module_overrides
    ->loadOverrides([
    'system.site',
  ]);
  $this
    ->assertEquals($expected, $result);
}