You are here

function module_test_system_info_alter in Drupal 7

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/module_test/module_test.module \module_test_system_info_alter()
  2. 9 core/modules/system/tests/modules/module_test/module_test.module \module_test_system_info_alter()
  3. 10 core/modules/system/tests/modules/module_test/module_test.module \module_test_system_info_alter()

Implements hook_system_info_alter().

Manipulate module dependencies to test dependency chains.

File

modules/simpletest/tests/module_test.module, line 17

Code

function module_test_system_info_alter(&$info, $file, $type) {
  if (variable_get('dependency_test', FALSE) == 'missing dependency') {
    if ($file->name == 'forum') {

      // Make forum module depend on poll.
      $info['dependencies'][] = 'poll';
    }
    elseif ($file->name == 'poll') {

      // Make poll depend on a made-up module.
      $info['dependencies'][] = 'foo';
    }
  }
  elseif (variable_get('dependency_test', FALSE) == 'dependency') {
    if ($file->name == 'forum') {

      // Make the forum module depend on poll.
      $info['dependencies'][] = 'poll';
    }
    elseif ($file->name == 'poll') {

      // Make poll depend on php module.
      $info['dependencies'][] = 'php';
    }
  }
  elseif (variable_get('dependency_test', FALSE) == 'version dependency') {
    if ($file->name == 'forum') {

      // Make the forum module depend on poll.
      $info['dependencies'][] = 'poll';
    }
    elseif ($file->name == 'poll') {

      // Make poll depend on a specific version of php module.
      $info['dependencies'][] = 'php (1.x)';
    }
    elseif ($file->name == 'php') {

      // Set php module to a version compatible with the above.
      $info['version'] = '7.x-1.0';
    }
  }
  if ($file->name == 'seven' && $type == 'theme') {
    $info['regions']['test_region'] = t('Test region');
  }
}