You are here

function ModuleImplementsAlterTestCase::testModuleImplementsAlter in Drupal 7

Tests hook_module_implements_alter() adding an implementation.

File

modules/simpletest/tests/module.test, line 318
Tests for the module API.

Class

ModuleImplementsAlterTestCase

Code

function testModuleImplementsAlter() {
  module_enable(array(
    'module_test',
  ), FALSE);
  $this
    ->assertTrue(module_exists('module_test'), 'Test module is enabled.');

  // Assert that module_test.module is now included.
  $this
    ->assertTrue(function_exists('module_test_permission'), 'The file module_test.module was successfully included.');
  $modules = module_implements('permission');
  $this
    ->assertTrue(in_array('module_test', $modules), 'module_test implements hook_permission.');
  $modules = module_implements('module_implements_alter');
  $this
    ->assertTrue(in_array('module_test', $modules), 'module_test implements hook_module_implements_alter().');

  // Assert that module_test.implementations.inc is not included yet.
  $this
    ->assertFalse(function_exists('module_test_altered_test_hook'), 'The file module_test.implementations.inc is not included yet.');

  // Assert that module_test_module_implements_alter(*, 'altered_test_hook')
  // has added an implementation
  $this
    ->assertTrue(in_array('module_test', module_implements('altered_test_hook')), 'module_test implements hook_altered_test_hook().');

  // Assert that module_test.implementations.inc was included as part of the process.
  $this
    ->assertTrue(function_exists('module_test_altered_test_hook'), 'The file module_test.implementations.inc was included.');
}