function ArgumentValidateTest::testArgumentValidateUserName in Views (for Drupal 7) 8.3
File
- lib/
Drupal/ views/ Tests/ User/ ArgumentValidateTest.php, line 44 - Definition of Drupal\views\Tests\User\ArgumentValidateTest.
Class
- ArgumentValidateTest
- Tests views user argument argument handler.
Namespace
Drupal\views\Tests\UserCode
function testArgumentValidateUserName() {
$account = $this->account;
// test 'name' case
$view = $this
->view_argument_validate_user('name');
$this
->assertTrue($view->argument['null']
->validateArgument($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']
->validateArgument($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']
->validateArgument($this
->randomName()));
}