You are here

function InfoAlterTest::testSystemInfoAlter in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/System/InfoAlterTest.php \Drupal\system\Tests\System\InfoAlterTest::testSystemInfoAlter()

Tests that theme .info.yml data is rebuild after enabling a module.

Tests that info data is rebuilt after a module that implements hook_system_info_alter() is enabled. Also tests if core *_list() functions return freshly altered info.

File

core/modules/system/src/Tests/System/InfoAlterTest.php, line 28
Contains \Drupal\system\Tests\System\InfoAlterTest.

Class

InfoAlterTest
Tests the effectiveness of hook_system_info_alter().

Namespace

Drupal\system\Tests\System

Code

function testSystemInfoAlter() {
  \Drupal::state()
    ->set('module_required_test.hook_system_info_alter', TRUE);
  $info = system_rebuild_module_data();
  $this
    ->assertFalse(isset($info['node']->info['required']), 'Before the module_required_test is installed the node module is not required.');

  // Enable the test module.
  \Drupal::service('module_installer')
    ->install(array(
    'module_required_test',
  ), FALSE);
  $this
    ->assertTrue(\Drupal::moduleHandler()
    ->moduleExists('module_required_test'), 'Test required module is enabled.');
  $info = system_rebuild_module_data();
  $this
    ->assertTrue($info['node']->info['required'], 'After the module_required_test is installed the node module is required.');
}