3 namespace Drupal\Tests\system\Kernel\System;
5 use Drupal\KernelTests\KernelTestBase;
8 * Tests the effectiveness of hook_system_info_alter().
12 class InfoAlterTest extends KernelTestBase {
14 public static $modules = ['system'];
17 * Tests that theme .info.yml data is rebuild after enabling a module.
19 * Tests that info data is rebuilt after a module that implements
20 * hook_system_info_alter() is enabled. Also tests if core *_list() functions
21 * return freshly altered info.
23 public function testSystemInfoAlter() {
24 \Drupal::state()->set('module_required_test.hook_system_info_alter', TRUE);
25 $info = system_rebuild_module_data();
26 $this->assertFalse(isset($info['node']->info['required']), 'Before the module_required_test is installed the node module is not required.');
28 // Enable the test module.
29 \Drupal::service('module_installer')->install(['module_required_test'], FALSE);
30 $this->assertTrue(\Drupal::moduleHandler()->moduleExists('module_required_test'), 'Test required module is enabled.');
32 $info = system_rebuild_module_data();
33 $this->assertTrue($info['node']->info['required'], 'After the module_required_test is installed the node module is required.');