diff --git a/core/modules/field/modules/text/text.test b/core/modules/field/modules/text/text.test
index 7c5b32f..0887e22 100644
--- a/core/modules/field/modules/text/text.test
+++ b/core/modules/field/modules/text/text.test
@@ -213,7 +213,8 @@ class TextFieldTestCase extends DrupalWebTestCase {
     $format_id = $format->format;
     $permission = filter_permission_name($format);
     $roles = $this->web_user->roles;
-    $role = end(array_keys($roles));
+    unset($roles[DRUPAL_AUTHENTICATED_ROLE]);
+    $role = key($roles);
     user_role_grant_permissions($role, array($permission));
     $this->drupalLogin($this->web_user);
 
diff --git a/core/modules/filter/filter.test b/core/modules/filter/filter.test
index a5565db..c951b6b 100644
--- a/core/modules/filter/filter.test
+++ b/core/modules/filter/filter.test
@@ -502,7 +502,8 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase {
   function testFormatRoles() {
     // Get the role name assigned to the regular user.
     $roles = $this->web_user->roles;
-    $role_name = end(array_keys($roles));
+    unset($roles[DRUPAL_AUTHENTICATED_ROLE]);
+    $role_name = key($roles);
 
     // Check that this role appears in the list of roles that have access to an
     // allowed text format, but does not appear in the list of roles that have
diff --git a/core/modules/user/user.test b/core/modules/user/user.test
index df13427..d57baad 100644
--- a/core/modules/user/user.test
+++ b/core/modules/user/user.test
@@ -1274,7 +1274,8 @@ class UserAdminTestCase extends DrupalWebTestCase {
 
     // Filter the users by role. Grab the system-generated role name for User C.
     $roles = $user_c->roles;
-    $edit['role'] = end(array_keys($roles));
+    unset($roles[DRUPAL_AUTHENTICATED_ROLE]);
+    $edit['role'] = key($roles);
     $this->drupalPost('admin/people', $edit, t('Refine'));
 
     // Check if the correct users show up when filtered by role.
