You are here

public function KernelTestBaseTest::testInstallConfig in SimpleTest 8.3

Tests expected behavior of installConfig().

File

src/Tests/KernelTestBaseTest.php, line 215

Class

KernelTestBaseTest
Tests KernelTestBase functionality.

Namespace

Drupal\simpletest\Tests

Code

public function testInstallConfig() {

  // The user module has configuration that depends on system.
  $this
    ->enableModules([
    'system',
  ]);
  $module = 'user';

  // Verify that default config can only be installed for enabled modules.
  try {
    $this
      ->installConfig([
      $module,
    ]);
    $this
      ->fail('Exception for non-enabled module found.');
  } catch (\Exception $e) {
    $this
      ->pass('Exception for non-enabled module found.');
  }
  $this
    ->assertFalse($this->container
    ->get('config.storage')
    ->exists('user.settings'));

  // Verify that default config can be installed.
  $this
    ->enableModules([
    'user',
  ]);
  $this
    ->installConfig([
    'user',
  ]);
  $this
    ->assertTrue($this->container
    ->get('config.storage')
    ->exists('user.settings'));
  $this
    ->assertTrue($this
    ->config('user.settings')
    ->get('register'));
}