function ArgumentValidateTest::testArgumentValidateUserUid in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/user/src/Tests/Views/ArgumentValidateTest.php \Drupal\user\Tests\Views\ArgumentValidateTest::testArgumentValidateUserUid()
Tests the User (ID) argument validator.
File
- core/
modules/ user/ src/ Tests/ Views/ ArgumentValidateTest.php, line 44 - Contains \Drupal\user\Tests\Views\ArgumentValidateTest.
Class
- ArgumentValidateTest
- Tests user argument validators for ID and name.
Namespace
Drupal\user\Tests\ViewsCode
function testArgumentValidateUserUid() {
$account = $this->account;
$view = Views::getView('test_view_argument_validate_user');
$this
->executeView($view);
$this
->assertTrue($view->argument['null']
->validateArgument($account
->id()));
// Reset 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));
$form = array();
$form_state = new FormState();
$view->argument['null']
->buildOptionsForm($form, $form_state);
$sanitized_id = ArgumentPluginBase::encodeValidatorId('entity:user');
$this
->assertTrue($form['validate']['options'][$sanitized_id]['roles']['#states']['visible'][':input[name="options[validate][options][' . $sanitized_id . '][restrict_roles]"]']['checked']);
}