public function TokenReplacementTest::testDisabledTokenReplacement in Tokens in Views Filter Criteria 8
Tests disabled token replacement in filters.
File
- tests/
src/ Kernel/ TokenReplacementTest.php, line 99
Class
- TokenReplacementTest
- Tests handler token replacement in filter.
Namespace
Drupal\Tests\token_views_filter\KernelCode
public function testDisabledTokenReplacement() {
$view = Views::getView('test_token_filter');
$view
->initDisplay();
// Disable token replacement.
$filters = $view->display_handler
->getOption('filters');
$filters['test_filter_string']['use_tokens'] = FALSE;
$filters['test_filter_numeric']['use_tokens'] = FALSE;
$filters['test_filter_numeric_between']['use_tokens'] = FALSE;
$filters['test_filter_date']['use_tokens'] = FALSE;
$filters['test_filter_datetime']['use_tokens'] = FALSE;
$view->display_handler
->overrideOption('filters', $filters);
$this
->executeView($view);
$this
->assertSame('[test:value:Drupal]', $view->filter['test_filter_string']->value);
$this
->assertSame([
'min' => '',
'max' => '',
'value' => '[test:value:333]',
], $view->filter['test_filter_numeric']->value);
$this
->assertSame([
'min' => '[test:value:111]',
'max' => '[test:value:999]',
'value' => '',
], $view->filter['test_filter_numeric_between']->value);
$this
->assertSame([
'min' => '',
'max' => '',
'value' => '[current-date:custom:Y-m-d]',
'type' => 'date',
], $view->filter['test_filter_date']->value);
$this
->assertSame([
'min' => '',
'max' => '',
'value' => '[current-date:custom:Y-m-d]',
'type' => 'date',
], $view->filter['test_filter_datetime']->value);
}