function ThemeUpdateTest::testThemeUpdates

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Theme/ThemeUpdateTest.php \Drupal\Tests\system\Functional\Theme\ThemeUpdateTest::testThemeUpdates()
  2. 11.x core/modules/system/tests/src/Functional/Theme/ThemeUpdateTest.php \Drupal\Tests\system\Functional\Theme\ThemeUpdateTest::testThemeUpdates()

Ensures preprocess functions run even for suggestion implementations.

The theme hook used by this test has its base preprocess function in a separate file, so this test also ensures that the file is correctly loaded when needed.

File

core/modules/system/tests/src/Functional/Theme/ThemeUpdateTest.php, line 30

Class

ThemeUpdateTest
Tests low-level theme functions.

Namespace

Drupal\Tests\system\Functional\Theme

Code

public function testThemeUpdates() : void {
    \Drupal::service('module_installer')->install([
        'test_module_required_by_theme',
    ]);
    $this->rebuildAll();
    \Drupal::state()->set('test_theme_depending_on_modules.system_info_alter', [
        'dependencies' => [
            'test_module_required_by_theme',
            'stark',
        ],
    ]);
    \Drupal::service('theme_installer')->install([
        'test_theme_depending_on_modules',
    ]);
    $this->assertTrue(\Drupal::service('theme_handler')->themeExists('test_theme_depending_on_modules'), 'test_theme_depending_on_modules theme installed');
    \Drupal::state()->set('test_theme_depending_on_modules.system_info_alter', FALSE);
    \Drupal::state()->set('test_theme_depending_on_modules.post_update', TRUE);
    $this->assertFalse(\Drupal::moduleHandler()->moduleExists('test_another_module_required_by_theme'));
    $this->runUpdates();
    $this->assertTrue(\Drupal::moduleHandler()->moduleExists('test_another_module_required_by_theme'));
    $this->assertSession()
        ->addressEquals('update.php/results');
    $this->assertSession()
        ->responseContains('test_theme_depending_on_modules theme');
    $this->assertSession()
        ->responseContains('Post update message from theme post update function');
}

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