Skip to content
Snippets Groups Projects
Verified Commit 2afadf48 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2684251 by pooja_sharma, sheldonreed3, smustgrave, jehon, Lendude:...

Issue #2684251 by pooja_sharma, sheldonreed3, smustgrave, jehon, Lendude: Global Token Replacements is not working correctly in href

(cherry picked from commit ca4535dd)
parent 42029802
Branches
Tags
16 merge requests!12212Issue #3445525 by alexpott, japerry, catch, mglaman, longwave: Add BC layer...,!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!8949Backport .gitlabci.yml changes.,!8738Issue #3424162 by camilledavis, dineshkumarbollu, smustgrave: Claro...,!8704Make greek characters available in ckeditor5,!8533Issue #3446962 by kim.pepper: Remove incorrectly added...,!8517Issue #3443748 by NexusNovaz, smustgrave: Testcase creates false positive,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #200742 canceled
......@@ -107,11 +107,14 @@ public function tokenForm(&$form, FormStateInterface $form_state) {
* will be replaced.
*/
public function tokenizeValue($value) {
// As we add the globalTokenForm() we also should replace the token here.
$value = $this->globalTokenReplace($value);
if ($this->options['tokenize']) {
$value = $this->view->getStyle()->tokenizeValue($value, 0);
}
// As we add the globalTokenForm() we also should replace the token here.
return $this->globalTokenReplace($value);
return $value;
}
}
<?php
declare(strict_types=1);
namespace Drupal\Tests\views\Kernel\Handler;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
/**
* Tests the token in text area handler.
*
* @group views
* @see \Drupal\views\Plugin\views\area\Text
*/
class AreaTextTokenTest extends ViewsKernelTestBase {
protected static $modules = ['system', 'user', 'filter'];
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = ['test_view'];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE): void {
parent::setUp();
$this->installConfig(['system', 'filter']);
$this->installEntitySchema('user');
}
/**
* Tests the token into text area plugin within header.
*/
public function testAreaTextToken(): void {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $this->container->get('renderer');
$view = Views::getView('test_view');
$view->setDisplay();
// Enable checkbox 'token replacement', add token into href in text header.
$string = '<a href="[site:url]">Added Site URL token in href</a>';
$view->displayHandlers->get('default')->overrideOption('header', [
'area' => [
'id' => 'area',
'table' => 'views',
'field' => 'area',
'content' => [
'value' => $string,
],
'tokenize' => TRUE,
],
]);
// Execute the view.
$this->executeView($view);
$build = $view->display_handler->handlers['header']['area']->render();
$replaced_token = \Drupal::token()->replace('[site:url]');
$desired_output = str_replace('[site:url]', $replaced_token, $string);
$this->assertEquals(check_markup($desired_output), $renderer->renderRoot($build), 'Global token assessed in href');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment