function module_test_system_info_alter

Same name in other branches
  1. 9 core/modules/system/tests/modules/module_test/module_test.module \module_test_system_info_alter()
  2. 8.9.x 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()
  4. 11.x 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');
    }
}

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