Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / src / Kernel / System / InfoAlterTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Kernel\System;
4
5 use Drupal\KernelTests\KernelTestBase;
6
7 /**
8  * Tests the effectiveness of hook_system_info_alter().
9  *
10  * @group system
11  */
12 class InfoAlterTest extends KernelTestBase {
13
14   public static $modules = ['system'];
15
16   /**
17    * Tests that theme .info.yml data is rebuild after enabling a module.
18    *
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.
22    */
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.');
27
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.');
31
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.');
34   }
35
36 }