function PluginBaseTest::testViewsTokenReplace
Tests that the token replacement in views works correctly.
File
- 
              core/
modules/ views/ tests/ src/ Kernel/ Plugin/ PluginBaseTest.php, line 35  
Class
- PluginBaseTest
 - Tests the PluginBase class.
 
Namespace
Drupal\Tests\views\Kernel\PluginCode
public function testViewsTokenReplace() : void {
  $text = '{{ langcode__value }} means {{ langcode }}';
  $tokens = [
    '{{ langcode }}' => Markup::create('English'),
    '{{ langcode__value }}' => 'en',
  ];
  $result = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($text, $tokens) {
    return $this->testPluginBase
      ->viewsTokenReplace($text, $tokens);
  });
  $this->assertSame('en means English', $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.