function ViewExecutableTest::testArgumentValidatorValueOverride

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testArgumentValidatorValueOverride()
  2. 8.9.x core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testArgumentValidatorValueOverride()
  3. 11.x core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testArgumentValidatorValueOverride()

Tests if argument overrides by validators are propagated to tokens.

File

core/modules/views/tests/src/Kernel/ViewExecutableTest.php, line 555

Class

ViewExecutableTest
Tests the ViewExecutable class.

Namespace

Drupal\Tests\views\Kernel

Code

public function testArgumentValidatorValueOverride() : void {
    $account = User::create([
        'name' => $this->randomString(),
    ]);
    $account->save();
    $view = Views::getView('test_argument_dependency');
    $view->setDisplay('page_1');
    $view->setArguments([
        (string) $account->id(),
        'this value should be replaced',
    ]);
    $view->execute();
    $account = User::load(1);
    $expected = [
        '{{ arguments.uid }}' => $account->label(),
        '{{ raw_arguments.uid }}' => (string) $account->id(),
    ];
    $this->assertEquals($expected, $view->build_info['substitutions']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.