$this->
drupalGet('test-user-bulk-form'
);
$this->
submitForm($edit, 'Apply to selected items'
);
$this->
assertSession()->
pageTextContains('No users selected.'
);
// Assign a role to a user.
$account =
$user_storage->
load($this->users
[0
]->
id());
$roles =
user_role_names(TRUE
);
unset($roles[RoleInterface::AUTHENTICATED_ID
]);
$role =
key($roles);
$this->
assertFalse($account->
hasRole($role), 'The user currently does not have a custom role.'
);
$edit =
[ 'user_bulk_form[1]' => TRUE,
'action' => 'user_add_role_action.' .
$role,
];
$this->
submitForm($edit, 'Apply to selected items'
);
// Re-load the user and check their roles.
$user_storage->
resetCache([$account->
id()]);
$account =
$user_storage->
load($account->
id());
$this->
assertTrue($account->
hasRole($role), 'The user now has the custom role.'
);
$edit =
[