Version 1
[yaffs-website] / web / core / modules / system / tests / src / Functional / Theme / ThemeEarlyInitializationTest.php
diff --git a/web/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php b/web/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
new file mode 100644 (file)
index 0000000..040dfab
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+namespace Drupal\Tests\system\Functional\Theme;
+
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Tests that the theme system can be correctly initialized early in the page
+ * request.
+ *
+ * @group Theme
+ */
+class ThemeEarlyInitializationTest extends BrowserTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['theme_test'];
+
+  /**
+   * Test that the theme system can generate output in a request listener.
+   */
+  public function testRequestListener() {
+    $this->drupalGet('theme-test/request-listener');
+    // Verify that themed output generated in the request listener appears.
+    $this->assertRaw('Themed output generated in a KernelEvents::REQUEST listener');
+    // Verify that the default theme's CSS still appears even though the theme
+    // system was initialized early.
+    $this->assertRaw('classy/css/components/action-links.css');
+  }
+
+}