1.20.x user_views_argument_validate.test UserViewsArgumentValidate::testArgumentValidateUserEither()

File

modules/user/tests/user_views_argument_validate.test, line 55
Definition of UserViewsArgumentValidate.

Class

UserViewsArgumentValidate
Tests views user argument argument handler.

Code

function testArgumentValidateUserEither() {
  $account = $this->account;
  // test 'either' case
  $view = $this->view_argument_validate_user('either');
  $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->assertTrue($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()));
  // Reset safed argument validation.
  $view->argument['null']->argument_validated = NULL;
  // Fail for a valid uid, but for a user that doesn't exist
  $this->assertFalse($view->argument['null']->validate_arg(32));
}