You are here

public function TokenReplacementTest::testTokenViewsReplacement in Tokens in Views Filter Criteria 8

Tests views tokens replacement in filters.

File

tests/src/Kernel/TokenReplacementTest.php, line 235

Class

TokenReplacementTest
Tests handler token replacement in filter.

Namespace

Drupal\Tests\token_views_filter\Kernel

Code

public function testTokenViewsReplacement() {
  $view = Views::getView('test_token_filter');
  $view
    ->initDisplay();

  // Disable token replacement.
  $filters = $view->display_handler
    ->getOption('filters');
  $filters['test_filter_string']['value'] = '[view:id]';
  $filters['test_filter_numeric']['value'] = [
    'min' => '',
    'max' => '',
    'value' => '[view:page-count]',
  ];
  $view->display_handler
    ->overrideOption('filters', $filters);
  $this
    ->executeView($view);
  $this
    ->assertSame('test_token_filter', $view->filter['test_filter_string']->value);
  $this
    ->assertSame([
    'min' => '',
    'max' => '',
    'value' => '1',
  ], $view->filter['test_filter_numeric']->value);
}