function ArgumentValidateTest::testArgumentValidateUserName

Same name in other branches
  1. 8.9.x core/modules/user/tests/src/Kernel/Views/ArgumentValidateTest.php \Drupal\Tests\user\Kernel\Views\ArgumentValidateTest::testArgumentValidateUserName()
  2. 10 core/modules/user/tests/src/Kernel/Views/ArgumentValidateTest.php \Drupal\Tests\user\Kernel\Views\ArgumentValidateTest::testArgumentValidateUserName()
  3. 11.x core/modules/user/tests/src/Kernel/Views/ArgumentValidateTest.php \Drupal\Tests\user\Kernel\Views\ArgumentValidateTest::testArgumentValidateUserName()

Tests the UserName argument validator.

File

core/modules/user/tests/src/Kernel/Views/ArgumentValidateTest.php, line 76

Class

ArgumentValidateTest
Tests user argument validators for ID and name.

Namespace

Drupal\Tests\user\Kernel\Views

Code

public function testArgumentValidateUserName() {
    $view = Views::getView('test_view_argument_validate_username');
    $this->executeView($view);
    $this->assertTrue($view->argument['null']
        ->validateArgument($this->account
        ->getAccountName()));
    // Reset argument validation.
    $view->argument['null']->argument_validated = NULL;
    // Fail for a valid string, but for a user that doesn't exist
    $this->assertFalse($view->argument['null']
        ->validateArgument($this->randomMachineName()));
}

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