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