You are here

function ArgumentValidateTest::testArgumentValidateUserUid in Views (for Drupal 7) 8.3

File

lib/Drupal/views/Tests/User/ArgumentValidateTest.php, line 29
Definition of Drupal\views\Tests\User\ArgumentValidateTest.

Class

ArgumentValidateTest
Tests views user argument argument handler.

Namespace

Drupal\views\Tests\User

Code

function testArgumentValidateUserUid() {
  $account = $this->account;

  // test 'uid' case
  $view = $this
    ->view_argument_validate_user('uid');
  $this
    ->assertTrue($view->argument['null']
    ->validateArgument($account->uid));

  // Reset safed argument validation.
  $view->argument['null']->argument_validated = NULL;

  // Fail for a string variable since type is 'uid'
  $this
    ->assertFalse($view->argument['null']
    ->validateArgument($account->name));

  // Reset safed argument validation.
  $view->argument['null']->argument_validated = NULL;

  // Fail for a valid numeric, but for a user that doesn't exist
  $this
    ->assertFalse($view->argument['null']
    ->validateArgument(32));
}