function ModuleTestBase::assertModuleConfig

Asserts that the default configuration of a module has been installed.

Parameters

string $module: The name of the module.

Return value

bool TRUE if configuration has been installed, FALSE otherwise.

2 calls to ModuleTestBase::assertModuleConfig()
EnableDisableTest::assertSuccessfulDisableAndUninstall in drupal/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
Disables and uninstalls a module and asserts that it was done correctly.
EnableDisableTest::testEnableDisable in drupal/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
Tests that all core modules can be enabled, disabled and uninstalled.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php, line 96
Definition of Drupal\system\Tests\Module\ModuleTestBase.

Class

ModuleTestBase
Helper class for module test cases.

Namespace

Drupal\system\Tests\Module

Code

function assertModuleConfig($module) {
  $module_config_dir = drupal_get_path('module', $module) . '/config';
  if (!is_dir($module_config_dir)) {
    return;
  }
  $module_file_storage = new FileStorage($module_config_dir);
  $names = $module_file_storage
    ->listAll($module . '.');

  // Verify that the config directory is not empty.
  $this
    ->assertTrue($names);

  // Look up each default configuration object name in the active
  // configuration, and if it exists, remove it from the stack.
  foreach ($names as $key => $name) {
    if (config($name)
      ->get()) {
      unset($names[$key]);
    }
  }

  // Verify that all configuration has been installed (which means that $names
  // is empty).
  return $this
    ->assertFalse($names, format_string('All default configuration of @module module found.', array(
    '@module' => $module,
  )));
}