public function PluginBaseTest::testViewsTokenReplaceWithDots in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Kernel/Plugin/PluginBaseTest.php \Drupal\Tests\views\Kernel\Plugin\PluginBaseTest::testViewsTokenReplaceWithDots()
- 9 core/modules/views/tests/src/Kernel/Plugin/PluginBaseTest.php \Drupal\Tests\views\Kernel\Plugin\PluginBaseTest::testViewsTokenReplaceWithDots()
Tests that the token replacement in views works correctly with dots.
File
- core/
modules/ views/ tests/ src/ Kernel/ Plugin/ PluginBaseTest.php, line 49 - Contains \Drupal\views\Tests\Plugin\PluginBaseTest.
Class
- PluginBaseTest
- Tests the PluginBase class.
Namespace
Drupal\Tests\views\Kernel\PluginCode
public function testViewsTokenReplaceWithDots() {
$text = '{{ argument.first }} comes before {{ argument.second }}';
$tokens = [
'{{ argument.first }}' => 'first',
'{{ argument.second }}' => 'second',
];
$result = \Drupal::service('renderer')
->executeInRenderContext(new RenderContext(), function () use ($text, $tokens) {
return $this->testPluginBase
->viewsTokenReplace($text, $tokens);
});
$this
->assertSame('first comes before second', $result);
// Test tokens with numeric indexes.
$text = '{{ argument.0.first }} comes before {{ argument.1.second }}';
$tokens = [
'{{ argument.0.first }}' => 'first',
'{{ argument.1.second }}' => 'second',
];
$result = \Drupal::service('renderer')
->executeInRenderContext(new RenderContext(), function () use ($text, $tokens) {
return $this->testPluginBase
->viewsTokenReplace($text, $tokens);
});
$this
->assertSame('first comes before second', $result);
}