function TwigDeprecationsTest::testHookThemeDeprecations

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Theme/TwigDeprecationsTest.php \Drupal\KernelTests\Core\Theme\TwigDeprecationsTest::testHookThemeDeprecations()

Test deprecating variables at definition in hook_theme().

File

core/tests/Drupal/KernelTests/Core/Theme/TwigDeprecationsTest.php, line 28

Class

TwigDeprecationsTest
Tests deprecating variables passed to twig templates.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testHookThemeDeprecations() : void {
    $element = [
        '#theme' => 'theme_test_deprecations_hook_theme',
        '#foo' => 'foo',
        '#bar' => 'bar',
    ];
    // Both 'foo' and 'bar' are deprecated in theme_test_hook_theme(),
    // but 'bar' is not used in theme-test-deprecations-hook-theme.html.twig.
    $this->expectDeprecation($this->getDeprecationMessage('foo'));
    $this->assertEquals('foo', $this->container
        ->get('renderer')
        ->renderRoot($element));
}

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