summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-02-04 11:32:31 (GMT)
committerAlex Pott2015-02-04 11:32:31 (GMT)
commit353a1609cc0c0a44c264314a6d1cc9ca003e300a (patch)
tree64856c5fd7f34ebff08185a652b16dc650597f7b
parent610e90e3495d3293106d00a2f94982526f86640a (diff)
Issue #2385211 by tadityar, subhojit777, hussainweb, cilefen, tibbsa: Clean-up user module test members - ensure property definition and use of camelCase naming convention
-rw-r--r--core/modules/user/src/Tests/Condition/UserRoleConditionTest.php6
-rw-r--r--core/modules/user/src/Tests/UserActionConfigSchemaTest.php7
-rw-r--r--core/modules/user/src/Tests/UserAdminLanguageTest.php8
-rw-r--r--core/modules/user/src/Tests/UserAutocompleteTest.php30
-rw-r--r--core/modules/user/src/Tests/UserBlocksTest.php2
-rw-r--r--core/modules/user/src/Tests/UserCancelTest.php4
-rw-r--r--core/modules/user/src/Tests/UserEntityCallbacksTest.php9
-rw-r--r--core/modules/user/src/Tests/UserEntityReferenceTest.php13
-rw-r--r--core/modules/user/src/Tests/UserPermissionsTest.php28
-rw-r--r--core/modules/user/src/Tests/UserPictureTest.php20
-rw-r--r--core/modules/user/src/Tests/UserRoleAdminTest.php13
-rw-r--r--core/modules/user/src/Tests/UserRolesAssignmentTest.php5
-rw-r--r--core/modules/user/src/Tests/UserSignatureTest.php52
-rw-r--r--core/modules/user/src/Tests/UserTranslationUITest.php2
-rw-r--r--core/modules/user/src/Tests/Views/ArgumentValidateTest.php7
15 files changed, 145 insertions, 61 deletions
diff --git a/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php b/core/modules/user/src/Tests/Condition/UserRoleConditionTest.php
index e6dcc45..306b09b 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 499500d..99c2df7 100644
--- a/core/modules/user/src/Tests/UserActionConfigSchemaTest.php
+++ b/core/modules/user/src/Tests/UserActionConfigSchemaTest.php
@@ -29,13 +29,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.
*/
function testValidUserActionConfigSchema() {
diff --git a/core/modules/user/src/Tests/UserAdminLanguageTest.php b/core/modules/user/src/Tests/UserAdminLanguageTest.php
index 5ef37ab..5c2f1e5 100644
--- a/core/modules/user/src/Tests/UserAdminLanguageTest.php
+++ b/core/modules/user/src/Tests/UserAdminLanguageTest.php
@@ -18,16 +18,16 @@ use Drupal\simpletest\WebTestBase;
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 2230e5b..52fff32 100644
--- a/core/modules/user/src/Tests/UserAutocompleteTest.php
+++ b/core/modules/user/src/Tests/UserAutocompleteTest.php
@@ -17,12 +17,27 @@ use Drupal\simpletest\WebTestBase;
* @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 @@ class UserAutocompleteTest extends WebTestBase {
*/
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() . '<script>alert();</script>';
$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 b81d038..62bd46c 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 472b9d5..c40f63b 100644
--- a/core/modules/user/src/Tests/UserCancelTest.php
+++ b/core/modules/user/src/Tests/UserCancelTest.php
@@ -111,8 +111,8 @@ class UserCancelTest extends WebTestBase {
$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 cf8af85..1834872 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 b511203..6ef28ee 100644
--- a/core/modules/user/src/Tests/UserEntityReferenceTest.php
+++ b/core/modules/user/src/Tests/UserEntityReferenceTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* @file
* Contains \Drupal\user\Tests\UserEntityReferenceTest.
@@ -17,12 +18,16 @@ use Drupal\system\Tests\Entity\EntityUnitTestBase;
class UserEntityReferenceTest extends EntityUnitTestBase {
/**
- * @var \Drupal\user\Entity\Role
+ * A randomly-generated role for testing purposes.
+ *
+ * @var \Drupal\user\Entity\RoleInterface
*/
protected $role1;
/**
- * @var \Drupal\user\Entity\Role
+ * A randomly-generated role for testing purposes.
+ *
+ * @var \Drupal\user\Entity\RoleInterface
*/
protected $role2;
@@ -79,7 +84,9 @@ class UserEntityReferenceTest extends EntityUnitTestBase {
$user3->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 ed937dc..7a8bb2e 100644
--- a/core/modules/user/src/Tests/UserPermissionsTest.php
+++ b/core/modules/user/src/Tests/UserPermissionsTest.php
@@ -17,16 +17,28 @@ use Drupal\user\RoleStorage;
* @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 @@ class UserPermissionsTest extends WebTestBase {
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 @@ class UserPermissionsTest extends WebTestBase {
* 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 @@ class UserPermissionsTest extends WebTestBase {
// 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 @@ class UserPermissionsTest extends WebTestBase {
$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 94c4a2f..2938e67 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 @@ class UserPictureTest extends WebTestBase {
* 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 @@ class UserPictureTest extends WebTestBase {
// 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 @@ class UserPictureTest extends WebTestBase {
* 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 @@ class UserPictureTest extends WebTestBase {
*/
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 26f4d00..4e8377d 100644
--- a/core/modules/user/src/Tests/UserRoleAdminTest.php
+++ b/core/modules/user/src/Tests/UserRoleAdminTest.php
@@ -17,16 +17,23 @@ use Drupal\user\Entity\Role;
*/
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 @@ class UserRoleAdminTest extends WebTestBase {
* 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 71c9482..79addc2 100644
--- a/core/modules/user/src/Tests/UserRolesAssignmentTest.php
+++ b/core/modules/user/src/Tests/UserRolesAssignmentTest.php
@@ -15,12 +15,11 @@ use Drupal\simpletest\WebTestBase;
* @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 b70c91d..dcccbdf 100644
--- a/core/modules/user/src/Tests/UserSignatureTest.php
+++ b/core/modules/user/src/Tests/UserSignatureTest.php
@@ -17,6 +17,34 @@ use Drupal\simpletest\WebTestBase;
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.
*
* @var array
@@ -35,7 +63,7 @@ class UserSignatureTest extends WebTestBase {
$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 @@ class UserSignatureTest extends WebTestBase {
),
),
));
- $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 @@ class UserSignatureTest extends WebTestBase {
$admin_permissions[] = $permission;
}
}
- $this->admin_user = $this->drupalCreateUser($admin_permissions);
+ $this->adminUser = $this->drupalCreateUser($admin_permissions);
}
/**
@@ -90,12 +118,12 @@ class UserSignatureTest extends WebTestBase {
$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 = "<h1>" . $this->randomMachineName() . "</h1>";
$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 @@ class UserSignatureTest extends WebTestBase {
// 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 5a98be4..524e645 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 7a68698..f89cc63 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();