Version 1
[yaffs-website] / web / core / modules / system / tests / src / Kernel / System / InfoAlterTest.php
diff --git a/web/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php b/web/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php
new file mode 100644 (file)
index 0000000..ebdac3c
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+namespace Drupal\Tests\system\Kernel\System;
+
+use Drupal\KernelTests\KernelTestBase;
+
+/**
+ * Tests the effectiveness of hook_system_info_alter().
+ *
+ * @group system
+ */
+class InfoAlterTest extends KernelTestBase {
+
+  public static $modules = ['system'];
+
+  /**
+   * 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.
+   */
+  public 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(['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.');
+  }
+
+}