function ThemeTest::testSuggestionPreprocessForDefaults

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

Ensures suggestion preprocess functions run for default 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/ThemeTest.php, line 177

Class

ThemeTest
Tests low-level theme functions.

Namespace

Drupal\Tests\system\Functional\Theme

Code

public function testSuggestionPreprocessForDefaults() {
    $this->config('system.theme')
        ->set('default', 'test_theme')
        ->save();
    // Test with both an unprimed and primed theme registry.
    drupal_theme_rebuild();
    for ($i = 0; $i < 2; $i++) {
        $this->drupalGet('theme-test/preprocess-suggestions');
        $items = $this->cssSelect('.suggestion');
        $expected_values = [
            'Suggestion',
            'Kitten',
            'Monkey',
            'Kitten',
            'Flamingo',
        ];
        foreach ($expected_values as $key => $value) {
            $this->assertEqual((string) $value, $items[$key]->getText());
        }
    }
}

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