You are here

public function ArgumentValidateTest::testArgumentValidateUserName in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Tests/Views/ArgumentValidateTest.php \Drupal\user\Tests\Views\ArgumentValidateTest::testArgumentValidateUserName()

Tests the UserName argument validator.

File

core/modules/user/src/Tests/Views/ArgumentValidateTest.php, line 66
Contains \Drupal\user\Tests\Views\ArgumentValidateTest.

Class

ArgumentValidateTest
Tests user argument validators for ID and name.

Namespace

Drupal\user\Tests\Views

Code

public function testArgumentValidateUserName() {
  $account = $this->account;
  $view = Views::getView('test_view_argument_validate_username');
  $this
    ->executeView($view);
  $this
    ->assertTrue($view->argument['null']
    ->validateArgument($account
    ->getUsername()));

  // 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()));
}