diff --git a/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php b/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php index e6dcc456eabbc506ad417761780b300f4299a6f9..306b09ba27b2cc32b2bfcbfe1314fc938a286378 100644 --- a/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php +++ b/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php @@ -29,21 +29,21 @@ class UserRoleConditionTest extends KernelTestBase { /** * An anonymous user for testing purposes. * - * @var \Drupal\user\Entity\User + * @var \Drupal\user\UserInterface */ protected $anonymous; /** * An authenticated user for testing purposes. * - * @var \Drupal\user\Entity\User + * @var \Drupal\user\UserInterface */ protected $authenticated; /** * A custom role for testing purposes. * - * @var \Drupal\user\Entity\Role + * @var \Drupal\user\Entity\RoleInterface */ protected $role; diff --git a/core/modules/user/src/Tests/UserActionConfigSchemaTest.php b/core/modules/user/src/Tests/UserActionConfigSchemaTest.php index 499500dfda019f50338ed1f776aed0e406e50d58..99c2df79771b43b41dac21554ccbc7ab61d949e2 100644 --- a/core/modules/user/src/Tests/UserActionConfigSchemaTest.php +++ b/core/modules/user/src/Tests/UserActionConfigSchemaTest.php @@ -28,13 +28,6 @@ class UserActionConfigSchemaTest extends KernelTestBase { */ public static $modules = array('system', 'user'); - /** - * A user with administrative permissions. - * - * @var \Drupal\user\UserInterface - */ - protected $adminUser; - /** * Tests whether the user action config schema are valid. */ diff --git a/core/modules/user/src/Tests/UserAdminLanguageTest.php b/core/modules/user/src/Tests/UserAdminLanguageTest.php index 5ef37ab284570588a4f4903bc4a5a61c0fd765b5..5c2f1e5f3f1186bff14d8e32c4b0e600e45a1507 100644 --- a/core/modules/user/src/Tests/UserAdminLanguageTest.php +++ b/core/modules/user/src/Tests/UserAdminLanguageTest.php @@ -18,16 +18,16 @@ class UserAdminLanguageTest extends WebTestBase { /** - * Administrator user for this test. + * A user with permission to access admin pages and administer languages. * - * @var \Drupal\user\Entity\User + * @var \Drupal\user\UserInterface */ protected $adminUser; /** - * Non-administrator user for this test. + * A non-administrator user for this test. * - * @var \Drupal\user\Entity\User + * @var \Drupal\user\UserInterface */ protected $regularUser; diff --git a/core/modules/user/src/Tests/UserAutocompleteTest.php b/core/modules/user/src/Tests/UserAutocompleteTest.php index 2230e5b01735a913bb73f5d2b64c816abff80f57..52fff325190f635862af877b3fe3c906877d4898 100644 --- a/core/modules/user/src/Tests/UserAutocompleteTest.php +++ b/core/modules/user/src/Tests/UserAutocompleteTest.php @@ -17,12 +17,27 @@ * @group user */ class UserAutocompleteTest extends WebTestBase { + + /** + * A regular user for testing. + * + * @var \Drupal\user\UserInterface + */ + protected $unprivilegedUser; + + /** + * A user with permission to access user profiles. + * + * @var \Drupal\user\UserInterface + */ + protected $privilegedUser; + protected function setUp() { parent::setUp(); // Set up two users with different permissions to test access. - $this->unprivileged_user = $this->drupalCreateUser(); - $this->privileged_user = $this->drupalCreateUser(array('access user profiles')); + $this->unprivilegedUser = $this->drupalCreateUser(); + $this->privilegedUser = $this->drupalCreateUser(array('access user profiles')); } /** @@ -30,19 +45,20 @@ protected function setUp() { */ function testUserAutocomplete() { // Check access from unprivileged user, should be denied. - $this->drupalLogin($this->unprivileged_user); - $username = $this->unprivileged_user->getUsername(); + $this->drupalLogin($this->unprivilegedUser); + $username = $this->unprivilegedUser->getUsername(); $this->drupalGet('user/autocomplete', array('query' => array('q' => $username[0]))); $this->assertResponse(403, 'Autocompletion access denied to user without permission.'); // Check access from privileged user. $this->drupalLogout(); - $this->drupalLogin($this->privileged_user); + $this->drupalLogin($this->privilegedUser); $this->drupalGet('user/autocomplete', array('query' => array('q' => $username[0]))); $this->assertResponse(200, 'Autocompletion access allowed.'); - // Using first letter of the user's name, make sure the user's full name is in the results. - $this->assertRaw($this->unprivileged_user->getUsername(), 'User name found in autocompletion results.'); + // Using first letter of the user's name, make sure the user's full name is + // in the results. + $this->assertRaw($this->unprivilegedUser->getUsername(), 'User name found in autocompletion results.'); $anonymous_name = $this->randomString() . ''; $this->config('user.settings')->set('anonymous', $anonymous_name)->save(); diff --git a/core/modules/user/src/Tests/UserBlocksTest.php b/core/modules/user/src/Tests/UserBlocksTest.php index b81d038a7d1f8de543c74410a45d73ecfd018880..62bd46ce14c982b414dd1578cd349774e7972a8a 100644 --- a/core/modules/user/src/Tests/UserBlocksTest.php +++ b/core/modules/user/src/Tests/UserBlocksTest.php @@ -24,7 +24,7 @@ class UserBlocksTest extends WebTestBase { public static $modules = array('block', 'views'); /** - * The admin user used in this test. + * A user with the 'administer blocks' permission. * * @var \Drupal\user\UserInterface */ diff --git a/core/modules/user/src/Tests/UserCancelTest.php b/core/modules/user/src/Tests/UserCancelTest.php index 472b9d5495c4d3d508e1826ea686484ca8ac97ae..c40f63bc8f50abfeacfd9b3a5422896d115ced94 100644 --- a/core/modules/user/src/Tests/UserCancelTest.php +++ b/core/modules/user/src/Tests/UserCancelTest.php @@ -111,8 +111,8 @@ function testUserCancelUid1() { $user1->pass_raw = $password; // Try to cancel uid 1's account with a different user. - $this->admin_user = $this->drupalCreateUser(array('administer users')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer users')); + $this->drupalLogin($admin_user); $edit = array( 'action' => 'user_cancel_user_action', 'user_bulk_form[0]' => TRUE, diff --git a/core/modules/user/src/Tests/UserEntityCallbacksTest.php b/core/modules/user/src/Tests/UserEntityCallbacksTest.php index cf8af85244dbfe6ee331821e7630f9e1dffc8be7..18348729fcb7b786afdbfddecd9c8fb3bf035985 100644 --- a/core/modules/user/src/Tests/UserEntityCallbacksTest.php +++ b/core/modules/user/src/Tests/UserEntityCallbacksTest.php @@ -25,10 +25,19 @@ class UserEntityCallbacksTest extends WebTestBase { public static $modules = array('user'); /** + * An authenticated user to use for testing. + * * @var \Drupal\user\UserInterface */ protected $account; + /** + * An anonymous user to use for testing. + * + * @var \Drupal\user\UserInterface + */ + protected $anonymous; + protected function setUp() { parent::setUp(); diff --git a/core/modules/user/src/Tests/UserEntityReferenceTest.php b/core/modules/user/src/Tests/UserEntityReferenceTest.php index b5112039db5913898dec478932239fcc5a7645e0..6ef28ee7a567d1e38731ddcd05d56c03005091a4 100644 --- a/core/modules/user/src/Tests/UserEntityReferenceTest.php +++ b/core/modules/user/src/Tests/UserEntityReferenceTest.php @@ -1,4 +1,5 @@ save(); - /** @var \Drupal\entity_reference\EntityReferenceAutocomplete $autocomplete */ + /** + * @var \Drupal\entity_reference\EntityReferenceAutocomplete $autocomplete + */ $autocomplete = \Drupal::service('entity_reference.autocomplete'); $matches = $autocomplete->getMatches($field_definition, 'user', 'user', 'NULL', '', 'aabb'); diff --git a/core/modules/user/src/Tests/UserPermissionsTest.php b/core/modules/user/src/Tests/UserPermissionsTest.php index ed937dc5075e223e2fc2b88daa1e04b43f2797f0..7a8bb2e18ff5972b2dd63e1e5e41d799a4be71d8 100644 --- a/core/modules/user/src/Tests/UserPermissionsTest.php +++ b/core/modules/user/src/Tests/UserPermissionsTest.php @@ -17,16 +17,28 @@ * @group user */ class UserPermissionsTest extends WebTestBase { - protected $admin_user; + + /** + * User with admin privileges. + * + * @var \Drupal\user\UserInterface + */ + protected $adminUser; + + /** + * User's role ID. + * + * @var string + */ protected $rid; protected function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'access user profiles', 'administer site configuration', 'administer modules', 'administer account settings')); + $this->adminUser = $this->drupalCreateUser(array('administer permissions', 'access user profiles', 'administer site configuration', 'administer modules', 'administer account settings')); // Find the new role ID. - $all_rids = $this->admin_user->getRoles(); + $all_rids = $this->adminUser->getRoles(); unset($all_rids[array_search(DRUPAL_AUTHENTICATED_RID, $all_rids)]); $this->rid = reset($all_rids); } @@ -37,9 +49,9 @@ protected function setUp() { function testUserPermissionChanges() { $permissions_hash_generator = $this->container->get('user.permissions_hash'); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $rid = $this->rid; - $account = $this->admin_user; + $account = $this->adminUser; $previous_permissions_hash = $permissions_hash_generator->generate($account); $this->assertIdentical($previous_permissions_hash, $permissions_hash_generator->generate($this->loggedInUser)); @@ -74,7 +86,7 @@ function testUserPermissionChanges() { * Test assigning of permissions for the administrator role. */ function testAdministratorRole() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalGet('admin/config/people/accounts'); // Verify that the administration role is none by default. @@ -89,7 +101,7 @@ function testAdministratorRole() { // permission is assigned by default. \Drupal::service('module_installer')->install(array('aggregator')); - $this->assertTrue($this->admin_user->hasPermission('administer news feeds'), 'The permission was automatically assigned to the administrator role'); + $this->assertTrue($this->adminUser->hasPermission('administer news feeds'), 'The permission was automatically assigned to the administrator role'); } /** @@ -99,7 +111,7 @@ function testUserRoleChangePermissions() { $permissions_hash_generator = $this->container->get('user.permissions_hash'); $rid = $this->rid; - $account = $this->admin_user; + $account = $this->adminUser; $previous_permissions_hash = $permissions_hash_generator->generate($account); // Verify current permissions. diff --git a/core/modules/user/src/Tests/UserPictureTest.php b/core/modules/user/src/Tests/UserPictureTest.php index 94c4a2f85ae1cd4d6331d752dd7a17961e76de15..2938e6733721f60619851fae580ce78282f04553 100644 --- a/core/modules/user/src/Tests/UserPictureTest.php +++ b/core/modules/user/src/Tests/UserPictureTest.php @@ -27,13 +27,17 @@ class UserPictureTest extends WebTestBase { */ protected $profile = 'standard'; - protected $user; - protected $_directory_test; + /** + * A regular user. + * + * @var \Drupal\user\UserInterface + */ + protected $webUser; protected function setUp() { parent::setUp(); - $this->web_user = $this->drupalCreateUser(array( + $this->webUser = $this->drupalCreateUser(array( 'access content', 'access comments', 'post comments', @@ -45,7 +49,7 @@ protected function setUp() { * Tests creation, display, and deletion of user pictures. */ function testCreateDeletePicture() { - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); // Save a new picture. $image = current($this->drupalGetTestFiles('image')); @@ -57,7 +61,7 @@ function testCreateDeletePicture() { // Delete the picture. $edit = array(); - $this->drupalPostForm('user/' . $this->web_user->id() . '/edit', $edit, t('Remove')); + $this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $edit, t('Remove')); $this->drupalPostForm(NULL, array(), t('Save')); // Call file_cron() to clean up the file. Make sure the timestamp @@ -82,7 +86,7 @@ function testCreateDeletePicture() { * Tests embedded users on node pages. */ function testPictureOnNodeComment() { - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); // Save a new picture. $image = current($this->drupalGetTestFiles('image')); @@ -124,10 +128,10 @@ function testPictureOnNodeComment() { */ function saveUserPicture($image) { $edit = array('files[user_picture_0]' => drupal_realpath($image->uri)); - $this->drupalPostForm('user/' . $this->web_user->id() . '/edit', $edit, t('Save')); + $this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $edit, t('Save')); // Load actual user data from database. - $account = user_load($this->web_user->id(), TRUE); + $account = user_load($this->webUser->id(), TRUE); return file_load($account->user_picture->target_id, TRUE); } } diff --git a/core/modules/user/src/Tests/UserRoleAdminTest.php b/core/modules/user/src/Tests/UserRoleAdminTest.php index 26f4d0078891cf1d181cb356dce9b3b3146d9d45..4e8377d5ef4c8c4e1a58ec26badc93fd41c3606c 100644 --- a/core/modules/user/src/Tests/UserRoleAdminTest.php +++ b/core/modules/user/src/Tests/UserRoleAdminTest.php @@ -17,16 +17,23 @@ */ class UserRoleAdminTest extends WebTestBase { + /** + * User with admin privileges. + * + * @var \Drupal\user\UserInterface + */ + protected $adminUser; + protected function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'administer users')); + $this->adminUser = $this->drupalCreateUser(array('administer permissions', 'administer users')); } /** * Test adding, renaming and deleting roles. */ function testRoleAdministration() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); // Test presence of tab. $this->drupalGet('admin/people/permissions'); @@ -85,7 +92,7 @@ function testRoleAdministration() { * Test user role weight change operation and ordering. */ function testRoleWeightOrdering() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $roles = user_roles(); $weight = count($roles); $new_role_weights = array(); diff --git a/core/modules/user/src/Tests/UserRolesAssignmentTest.php b/core/modules/user/src/Tests/UserRolesAssignmentTest.php index 71c9482230a0ebc9d49c30666436c5b4a517068a..79addc2d7472c334ab180f568f7f724bffc396fd 100644 --- a/core/modules/user/src/Tests/UserRolesAssignmentTest.php +++ b/core/modules/user/src/Tests/UserRolesAssignmentTest.php @@ -15,12 +15,11 @@ * @group user */ class UserRolesAssignmentTest extends WebTestBase { - protected $admin_user; protected function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'administer users')); - $this->drupalLogin($this->admin_user); + $admin_user = $this->drupalCreateUser(array('administer permissions', 'administer users')); + $this->drupalLogin($admin_user); } /** diff --git a/core/modules/user/src/Tests/UserSignatureTest.php b/core/modules/user/src/Tests/UserSignatureTest.php index b70c91de463b208e294b4037072ac6302248d682..dcccbdf9e3e51f15e197b288c3c68cae42a55c14 100644 --- a/core/modules/user/src/Tests/UserSignatureTest.php +++ b/core/modules/user/src/Tests/UserSignatureTest.php @@ -16,6 +16,34 @@ */ class UserSignatureTest extends WebTestBase { + /** + * A regular user. + * + * @var \Drupal\user\UserInterface + */ + protected $webUser; + + /** + * User with admin privileges. + * + * @var \Drupal\user\UserInterface + */ + protected $adminUser; + + /** + * Filtered HTML format. + * + * @var \Drupal\filter\FilterFormatInterface + */ + protected $filteredHtmlFormat; + + /** + * Full HTML format. + * + * @var \Drupal\filter\FilterFormatInterface + */ + protected $fullHtmlFormat; + /** * Modules to enable. * @@ -35,7 +63,7 @@ protected function setUp() { $this->container->get('comment.manager')->addDefaultField('node', 'page'); // Prefetch and create text formats. - $this->filtered_html_format = entity_create('filter_format', array( + $this->filteredHtmlFormat = entity_create('filter_format', array( 'format' => 'filtered_html_format', 'name' => 'Filtered HTML', 'weight' => -1, @@ -49,18 +77,18 @@ protected function setUp() { ), ), )); - $this->filtered_html_format->save(); + $this->filteredHtmlFormat->save(); - $this->full_html_format = entity_create('filter_format', array( + $this->fullHtmlFormat = entity_create('filter_format', array( 'format' => 'full_html', 'name' => 'Full HTML', )); - $this->full_html_format->save(); + $this->fullHtmlFormat->save(); - user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array($this->filtered_html_format->getPermissionName())); + user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array($this->filteredHtmlFormat->getPermissionName())); // Create regular and administrative users. - $this->web_user = $this->drupalCreateUser(array('post comments')); + $this->webUser = $this->drupalCreateUser(array('post comments')); $admin_permissions = array('post comments', 'administer comments', 'administer user form display', 'administer account settings'); foreach (filter_formats() as $format) { @@ -68,7 +96,7 @@ protected function setUp() { $admin_permissions[] = $permission; } } - $this->admin_user = $this->drupalCreateUser($admin_permissions); + $this->adminUser = $this->drupalCreateUser($admin_permissions); } /** @@ -90,12 +118,12 @@ function testUserSignature() { $this->assertNoText(t('Signature')); // Log in as a regular user and create a signature. - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); $signature_text = "

" . $this->randomMachineName() . "

"; $edit = array( 'signature[value]' => $signature_text, ); - $this->drupalPostForm('user/' . $this->web_user->id() . '/edit', $edit, t('Save')); + $this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $edit, t('Save')); // Verify that values were stored. $this->assertFieldByName('signature[value]', $edit['signature[value]'], 'Submitted signature text found.'); @@ -118,14 +146,14 @@ function testUserSignature() { // Log in as an administrator and edit the comment to use Full HTML, so // that the comment text itself is not filtered at all. - $this->drupalLogin($this->admin_user); - $edit['comment_body[0][format]'] = $this->full_html_format->id(); + $this->drupalLogin($this->adminUser); + $edit['comment_body[0][format]'] = $this->fullHtmlFormat->id(); $this->drupalPostForm('comment/' . $comment_id . '/edit', $edit, t('Save')); // Assert that the signature did not make it through unfiltered. $this->drupalGet('node/' . $node->id()); $this->assertNoRaw($signature_text, 'Unfiltered signature text not found.'); - $this->assertRaw(check_markup($signature_text, $this->filtered_html_format->id()), 'Filtered signature text found.'); + $this->assertRaw(check_markup($signature_text, $this->filteredHtmlFormat->id()), 'Filtered signature text found.'); // Verify that the user signature's text format's cache tag is present. $this->drupalGet('node/' . $node->id()); $this->assertTrue(in_array('config:filter.format.filtered_html_format', explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags')))); diff --git a/core/modules/user/src/Tests/UserTranslationUITest.php b/core/modules/user/src/Tests/UserTranslationUITest.php index 5a98be4ff2d85d365b1dc82391c1ac3f088da9b1..524e64529be20ff506dc38fe7e77de1ab1d5e22c 100644 --- a/core/modules/user/src/Tests/UserTranslationUITest.php +++ b/core/modules/user/src/Tests/UserTranslationUITest.php @@ -18,6 +18,8 @@ class UserTranslationUITest extends ContentTranslationUITest { /** * The user name of the test user. + * + * @var string */ protected $name; diff --git a/core/modules/user/src/Tests/Views/ArgumentValidateTest.php b/core/modules/user/src/Tests/Views/ArgumentValidateTest.php index 7a6869835889545203a90d2ae521dc1729460ae1..f89cc63cf4ec6bc8a89dfc32c58434397babd2eb 100644 --- a/core/modules/user/src/Tests/Views/ArgumentValidateTest.php +++ b/core/modules/user/src/Tests/Views/ArgumentValidateTest.php @@ -25,6 +25,13 @@ class ArgumentValidateTest extends UserTestBase { */ public static $testViews = array('test_view_argument_validate_user', 'test_view_argument_validate_username'); + /** + * A user for this test. + * + * @var \Drupal\user\UserInterface + */ + protected $account; + protected function setUp() { parent::setUp();