summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2012-06-04 01:07:43 -0400
committerDavid Rothstein <drothstein@gmail.com>2012-06-04 01:07:43 -0400
commitbbe4b34681f9bb52c344ac4475c1adc7b5c3f601 (patch)
treebf05ebf2c6df41b141eaf9f3f04737d894449a4c /modules
parent31a4cbdb0e804a66ef3f602450c872cefa949cbb (diff)
downloadbrdo-bbe4b34681f9bb52c344ac4475c1adc7b5c3f601.tar.gz
brdo-bbe4b34681f9bb52c344ac4475c1adc7b5c3f601.tar.bz2
Issue #1600892 by tim.plunkett, sun: Fixed Tests use magic numbers 1 and 2 instead of user role constants.
Diffstat (limited to 'modules')
-rw-r--r--modules/block/block.test4
-rw-r--r--modules/book/book.test8
-rw-r--r--modules/file/tests/file.test2
-rw-r--r--modules/filter/filter.test16
-rw-r--r--modules/php/php.test4
-rw-r--r--modules/user/user.test10
6 files changed, 24 insertions, 20 deletions
diff --git a/modules/block/block.test b/modules/block/block.test
index cdd0d4589..8e6e47042 100644
--- a/modules/block/block.test
+++ b/modules/block/block.test
@@ -97,7 +97,7 @@ class BlockTestCase extends DrupalWebTestCase {
// Set visibility only for authenticated users, to verify delete functionality.
$edit = array();
- $edit['roles[2]'] = TRUE;
+ $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = TRUE;
$this->drupalPost('admin/structure/block/manage/block/' . $bid . '/configure', $edit, t('Save block'));
// Delete the created custom block & verify that it's been deleted and no longer appearing on the page.
@@ -171,7 +171,7 @@ class BlockTestCase extends DrupalWebTestCase {
// authenticated users.
$edit = array();
$edit['pages'] = 'user*';
- $edit['roles[2]'] = TRUE;
+ $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = TRUE;
$this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', $edit, t('Save block'));
// Move block to the first sidebar.
diff --git a/modules/book/book.test b/modules/book/book.test
index 6c351b8ec..1ec1fe92f 100644
--- a/modules/book/book.test
+++ b/modules/book/book.test
@@ -279,8 +279,8 @@ class BookTestCase extends DrupalWebTestCase {
// Give anonymous users the permission 'node test view'.
$edit = array();
- $edit['1[node test view]'] = TRUE;
- $this->drupalPost('admin/people/permissions/1', $edit, t('Save permissions'));
+ $edit[DRUPAL_ANONYMOUS_RID . '[node test view]'] = TRUE;
+ $this->drupalPost('admin/people/permissions/' . DRUPAL_ANONYMOUS_RID, $edit, t('Save permissions'));
$this->assertText(t('The changes have been saved.'), t("Permission 'node test view' successfully assigned to anonymous users."));
// Test correct display of the block.
@@ -315,8 +315,8 @@ class BookTestCase extends DrupalWebTestCase {
// Give anonymous users the permission 'node test view'.
$edit = array();
- $edit['1[node test view]'] = TRUE;
- $this->drupalPost('admin/people/permissions/1', $edit, t('Save permissions'));
+ $edit[DRUPAL_ANONYMOUS_RID . '[node test view]'] = TRUE;
+ $this->drupalPost('admin/people/permissions/' . DRUPAL_ANONYMOUS_RID, $edit, t('Save permissions'));
$this->assertText(t('The changes have been saved.'), t('Permission \'node test view\' successfully assigned to anonymous users.'));
// Create a book.
diff --git a/modules/file/tests/file.test b/modules/file/tests/file.test
index 7fa6d6f01..76708a3c7 100644
--- a/modules/file/tests/file.test
+++ b/modules/file/tests/file.test
@@ -551,7 +551,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase {
// Remove access comments permission from anon user.
$edit = array(
- '1[access comments]' => FALSE,
+ DRUPAL_ANONYMOUS_RID . '[access comments]' => FALSE,
);
$this->drupalPost('admin/people/permissions', $edit, t('Save permissions'));
diff --git a/modules/filter/filter.test b/modules/filter/filter.test
index 5471f2da3..aa1693fba 100644
--- a/modules/filter/filter.test
+++ b/modules/filter/filter.test
@@ -314,7 +314,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$edit = array();
$edit['format'] = drupal_strtolower($this->randomName());
$edit['name'] = $this->randomName();
- $edit['roles[2]'] = 1;
+ $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = 1;
$edit['filters[' . $second_filter . '][status]'] = TRUE;
$edit['filters[' . $first_filter . '][status]'] = TRUE;
$this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration'));
@@ -324,7 +324,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$format = filter_format_load($edit['format']);
$this->assertNotNull($format, t('Format found in database.'));
- $this->assertFieldByName('roles[2]', '', t('Role found.'));
+ $this->assertFieldByName('roles[' . DRUPAL_AUTHENTICATED_RID . ']', '', t('Role found.'));
$this->assertFieldByName('filters[' . $second_filter . '][status]', '', t('Line break filter found.'));
$this->assertFieldByName('filters[' . $first_filter . '][status]', '', t('Url filter found.'));
@@ -335,8 +335,8 @@ class FilterAdminTestCase extends DrupalWebTestCase {
// Allow authenticated users on full HTML.
$format = filter_format_load($full);
$edit = array();
- $edit['roles[1]'] = 0;
- $edit['roles[2]'] = 1;
+ $edit['roles[' . DRUPAL_ANONYMOUS_RID . ']'] = 0;
+ $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = 1;
$this->drupalPost('admin/config/content/formats/' . $full, $edit, t('Save configuration'));
$this->assertRaw(t('The text format %format has been updated.', array('%format' => $format->name)), t('Full HTML format successfully updated.'));
@@ -386,10 +386,10 @@ class FilterAdminTestCase extends DrupalWebTestCase {
// Full HTML.
$edit = array();
- $edit['roles[2]'] = FALSE;
+ $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = FALSE;
$this->drupalPost('admin/config/content/formats/' . $full, $edit, t('Save configuration'));
$this->assertRaw(t('The text format %format has been updated.', array('%format' => $format->name)), t('Full HTML format successfully reverted.'));
- $this->assertFieldByName('roles[2]', $edit['roles[2]'], t('Changes reverted.'));
+ $this->assertFieldByName('roles[' . DRUPAL_AUTHENTICATED_RID . ']', $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'], t('Changes reverted.'));
// Filter order.
$edit = array();
@@ -1807,7 +1807,7 @@ class FilterHooksTestCase extends DrupalWebTestCase {
$edit = array();
$edit['format'] = drupal_strtolower($this->randomName());
$edit['name'] = $name;
- $edit['roles[1]'] = 1;
+ $edit['roles[' . DRUPAL_ANONYMOUS_RID . ']'] = 1;
$this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration'));
$this->assertRaw(t('Added text format %format.', array('%format' => $name)), t('New format created.'));
$this->assertText('hook_filter_format_insert invoked.', t('hook_filter_format_insert was invoked.'));
@@ -1816,7 +1816,7 @@ class FilterHooksTestCase extends DrupalWebTestCase {
// Update text format.
$edit = array();
- $edit['roles[2]'] = 1;
+ $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = 1;
$this->drupalPost('admin/config/content/formats/' . $format_id, $edit, t('Save configuration'));
$this->assertRaw(t('The text format %format has been updated.', array('%format' => $name)), t('Format successfully updated.'));
$this->assertText('hook_filter_format_update invoked.', t('hook_filter_format_update() was invoked.'));
diff --git a/modules/php/php.test b/modules/php/php.test
index 50fb55283..b68bd501d 100644
--- a/modules/php/php.test
+++ b/modules/php/php.test
@@ -33,8 +33,8 @@ class PHPTestCase extends DrupalWebTestCase {
// Verify that anonymous and authenticated user roles do not have access.
$this->drupalGet('admin/config/content/formats/' . $php_format_id);
- $this->assertFieldByName('roles[1]', FALSE, t('Anonymous users do not have access to PHP code format.'));
- $this->assertFieldByName('roles[2]', FALSE, t('Authenticated users do not have access to PHP code format.'));
+ $this->assertFieldByName('roles[' . DRUPAL_ANONYMOUS_RID . ']', FALSE, t('Anonymous users do not have access to PHP code format.'));
+ $this->assertFieldByName('roles[' . DRUPAL_AUTHENTICATED_RID . ']', FALSE, t('Authenticated users do not have access to PHP code format.'));
}
/**
diff --git a/modules/user/user.test b/modules/user/user.test
index 2efe5b070..9413ed5ee 100644
--- a/modules/user/user.test
+++ b/modules/user/user.test
@@ -2119,9 +2119,13 @@ class UserRolesAssignmentTestCase extends DrupalWebTestCase {
/**
* Check role on user object.
*
- * @param object $account User.
- * @param integer $rid Role id.
- * @param bool $is_assigned True if the role should present on the account.
+ * @param object $account
+ * The user account to check.
+ * @param string $rid
+ * The role ID to search for.
+ * @param bool $is_assigned
+ * (optional) Whether to assert that $rid exists (TRUE) or not (FALSE).
+ * Defaults to TRUE.
*/
private function userLoadAndCheckRoleAssigned($account, $rid, $is_assigned = TRUE) {
$account = user_load($account->uid, TRUE);