You are here

function ViewsUserArgumentValidate::testArgumentValidateUserName in Views (for Drupal 7) 7.3

File

tests/user/views_user_argument_validate.test, line 48
Definition of ViewsUserArgumentValidate.

Class

ViewsUserArgumentValidate
Tests views user argument argument handler.

Code

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

  // test 'name' case.
  $view = $this
    ->view_argument_validate_user('name');
  $view
    ->set_display('default');
  $view
    ->pre_execute();
  $view
    ->init_handlers();
  $this
    ->assertTrue($view->argument['null']
    ->validate_arg($account->name));

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

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

  // Reset safed 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']
    ->validate_arg($this
    ->randomName()));
}