ThemeEarlyInitializationTest.php

Same filename in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
  2. 10 core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
  3. 11.x core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php

Namespace

Drupal\Tests\system\Functional\Theme

File

core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php

View source
<?php

namespace Drupal\Tests\system\Functional\Theme;

use Drupal\Tests\BrowserTestBase;

/**
 * Tests theme system initialization early in the page request.
 *
 * @group Theme
 */
class ThemeEarlyInitializationTest extends BrowserTestBase {
    
    /**
     * Modules to enable.
     *
     * @var array
     */
    protected static $modules = [
        'theme_test',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected $defaultTheme = 'starterkit_theme';
    
    /**
     * Tests 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->assertSession()
            ->responseContains('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->assertSession()
            ->responseContains('starterkit_theme/css/components/action-links.css');
    }

}

Classes

Title Deprecated Summary
ThemeEarlyInitializationTest Tests theme system initialization early in the page request.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.