Commit 408b1cf0 authored by jhodgdon's avatar jhodgdon

Issue #1798386 by Lars Toomre: Remove t() from test assert messages in user module

parent cbc23e2f
......@@ -39,14 +39,14 @@ function testUserAdmin() {
$admin_user = $this->drupalCreateUser(array('administer users'));
$this->drupalLogin($admin_user);
$this->drupalGet('admin/people');
$this->assertText($user_a->name, t('Found user A on admin users page'));
$this->assertText($user_b->name, t('Found user B on admin users page'));
$this->assertText($user_c->name, t('Found user C on admin users page'));
$this->assertText($admin_user->name, t('Found Admin user on admin users page'));
$this->assertText($user_a->name, 'Found user A on admin users page');
$this->assertText($user_b->name, 'Found user B on admin users page');
$this->assertText($user_c->name, 'Found user C on admin users page');
$this->assertText($admin_user->name, 'Found Admin user on admin users page');
// Test for existence of edit link in table.
$link = l(t('edit'), "user/$user_a->uid/edit", array('query' => array('destination' => 'admin/people')));
$this->assertRaw($link, t('Found user A edit link on admin users page'));
$this->assertRaw($link, 'Found user A edit link on admin users page');
// Filter the users by permission 'administer taxonomy'.
$edit = array();
......@@ -54,9 +54,9 @@ function testUserAdmin() {
$this->drupalPost('admin/people', $edit, t('Filter'));
// Check if the correct users show up.
$this->assertNoText($user_a->name, t('User A not on filtered by perm admin users page'));
$this->assertText($user_b->name, t('Found user B on filtered by perm admin users page'));
$this->assertText($user_c->name, t('Found user C on filtered by perm admin users page'));
$this->assertNoText($user_a->name, 'User A not on filtered by perm admin users page');
$this->assertText($user_b->name, 'Found user B on filtered by perm admin users page');
$this->assertText($user_c->name, 'Found user C on filtered by perm admin users page');
// Filter the users by role. Grab the system-generated role name for User C.
$roles = $user_c->roles;
......@@ -65,9 +65,9 @@ function testUserAdmin() {
$this->drupalPost('admin/people', $edit, t('Refine'));
// Check if the correct users show up when filtered by role.
$this->assertNoText($user_a->name, t('User A not on filtered by role on admin users page'));
$this->assertNoText($user_b->name, t('User B not on filtered by role on admin users page'));
$this->assertText($user_c->name, t('User C on filtered by role on admin users page'));
$this->assertNoText($user_a->name, 'User A not on filtered by role on admin users page');
$this->assertNoText($user_b->name, 'User B not on filtered by role on admin users page');
$this->assertText($user_c->name, 'User C on filtered by role on admin users page');
// Test blocking of a user.
$account = user_load($user_c->uid);
......
......@@ -15,9 +15,9 @@
class UserAuthmapAssignmentTest extends WebTestBase {
public static function getInfo() {
return array(
'name' => t('Authmap assignment'),
'description' => t('Tests that users can be assigned and unassigned authmaps.'),
'group' => t('User')
'name' => 'Authmap assignment',
'description' => 'Tests that users can be assigned and unassigned authmaps.',
'group' => 'User'
);
}
......@@ -44,7 +44,7 @@ function testAuthmapAssignment() {
),
);
foreach ($expected_authmaps as $authname => $expected_output) {
$this->assertIdentical(user_get_authmaps($authname), $expected_output, t('Authmap for authname %authname was set correctly.', array('%authname' => $authname)));
$this->assertIdentical(user_get_authmaps($authname), $expected_output, format_string('Authmap for authname %authname was set correctly.', array('%authname' => $authname)));
}
// Remove authmap for module poll, add authmap for module blog.
......@@ -57,13 +57,13 @@ function testAuthmapAssignment() {
// Assert that external username one does not have authmaps.
$remove_username = 'external username one';
unset($expected_authmaps[$remove_username]);
$this->assertFalse(user_get_authmaps($remove_username), t('Authmap for %authname was removed.', array('%authname' => $remove_username)));
$this->assertFalse(user_get_authmaps($remove_username), format_string('Authmap for %authname was removed.', array('%authname' => $remove_username)));
// Assert that a new authmap was created for external username three, and
// existing authmaps for external username two were unchanged.
$expected_authmaps['external username three'] = array('blog' => 'external username three');
foreach ($expected_authmaps as $authname => $expected_output) {
$this->assertIdentical(user_get_authmaps($authname), $expected_output, t('Authmap for authname %authname was set correctly.', array('%authname' => $authname)));
$this->assertIdentical(user_get_authmaps($authname), $expected_output, format_string('Authmap for authname %authname was set correctly.', array('%authname' => $authname)));
}
}
}
......@@ -36,15 +36,15 @@ function testUserAutocomplete() {
// Check access from unprivileged user, should be denied.
$this->drupalLogin($this->unprivileged_user);
$this->drupalGet('user/autocomplete/' . $this->unprivileged_user->name[0]);
$this->assertResponse(403, t('Autocompletion access denied to user without permission.'));
$this->assertResponse(403, 'Autocompletion access denied to user without permission.');
// Check access from privileged user.
$this->drupalLogout();
$this->drupalLogin($this->privileged_user);
$this->drupalGet('user/autocomplete/' . $this->unprivileged_user->name[0]);
$this->assertResponse(200, t('Autocompletion access allowed.'));
$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->name, t('User name found in autocompletion results.'));
$this->assertRaw($this->unprivileged_user->name, 'User name found in autocompletion results.');
}
}
......@@ -61,23 +61,23 @@ function testUserLoginBlock() {
$edit['name'] = $user->name;
$edit['pass'] = $user->pass_raw;
$this->drupalPost('admin/people/permissions', $edit, t('Log in'));
$this->assertNoText(t('User login'), t('Logged in.'));
$this->assertNoText(t('User login'), 'Logged in.');
// Check that we are still on the same page.
$this->assertEqual(url('admin/people/permissions', array('absolute' => TRUE)), $this->getUrl(), t('Still on the same page after login for access denied page'));
$this->assertEqual(url('admin/people/permissions', array('absolute' => TRUE)), $this->getUrl(), 'Still on the same page after login for access denied page');
// Now, log out and repeat with a non-403 page.
$this->drupalLogout();
$this->drupalPost('filter/tips', $edit, t('Log in'));
$this->assertNoText(t('User login'), t('Logged in.'));
$this->assertPattern('!<title.*?' . t('Compose tips') . '.*?</title>!', t('Still on the same page after login for allowed page'));
$this->assertNoText(t('User login'), 'Logged in.');
$this->assertPattern('!<title.*?' . t('Compose tips') . '.*?</title>!', 'Still on the same page after login for allowed page');
// Check that the user login block is not vulnerable to information
// disclosure to third party sites.
$this->drupalLogout();
$this->drupalPost('http://example.com/', $edit, t('Log in'), array('external' => FALSE));
// Check that we remain on the site after login.
$this->assertEqual(url('user/' . $user->uid, array('absolute' => TRUE)), $this->getUrl(), t('Redirected to user profile page after login from the frontpage'));
$this->assertEqual(url('user/' . $user->uid, array('absolute' => TRUE)), $this->getUrl(), 'Redirected to user profile page after login from the frontpage');
}
/**
......@@ -88,12 +88,12 @@ function testWhosOnlineBlock() {
$user1 = $this->drupalCreateUser(array());
$user2 = $this->drupalCreateUser(array());
$user3 = $this->drupalCreateUser(array());
$this->assertEqual(db_query("SELECT COUNT(*) FROM {sessions}")->fetchField(), 0, t('Sessions table is empty.'));
$this->assertEqual(db_query("SELECT COUNT(*) FROM {sessions}")->fetchField(), 0, 'Sessions table is empty.');
// Insert a user with two sessions.
$this->insertSession(array('uid' => $user1->uid));
$this->insertSession(array('uid' => $user1->uid));
$this->assertEqual(db_query("SELECT COUNT(*) FROM {sessions} WHERE uid = :uid", array(':uid' => $user1->uid))->fetchField(), 2, t('Duplicate user session has been inserted.'));
$this->assertEqual(db_query("SELECT COUNT(*) FROM {sessions} WHERE uid = :uid", array(':uid' => $user1->uid))->fetchField(), 2, 'Duplicate user session has been inserted.');
// Insert a user with only one session.
$this->insertSession(array('uid' => $user2->uid, 'timestamp' => REQUEST_TIME + 1));
......@@ -109,11 +109,11 @@ function testWhosOnlineBlock() {
$block = user_block_view('online');
$block['content'] = render($block['content']);
$this->drupalSetContent($block['content']);
$this->assertRaw(t('2 users'), t('Correct number of online users (2 users).'));
$this->assertText($user1->name, t('Active user 1 found in online list.'));
$this->assertText($user2->name, t('Active user 2 found in online list.'));
$this->assertNoText($user3->name, t("Inactive user not found in online list."));
$this->assertTrue(strpos($this->drupalGetContent(), $user1->name) > strpos($this->drupalGetContent(), $user2->name), t('Online users are ordered correctly.'));
$this->assertRaw(t('2 users'), 'Correct number of online users (2 users).');
$this->assertText($user1->name, 'Active user 1 found in online list.');
$this->assertText($user2->name, 'Active user 2 found in online list.');
$this->assertNoText($user3->name, 'Inactive user not found in online list.');
$this->assertTrue(strpos($this->drupalGetContent(), $user1->name) > strpos($this->drupalGetContent(), $user2->name), 'Online users are ordered correctly.');
}
/**
......@@ -129,6 +129,6 @@ private function insertSession(array $fields = array()) {
db_insert('sessions')
->fields($fields)
->execute();
$this->assertEqual(db_query("SELECT COUNT(*) FROM {sessions} WHERE uid = :uid AND sid = :sid AND timestamp = :timestamp", array(':uid' => $fields['uid'], ':sid' => $fields['sid'], ':timestamp' => $fields['timestamp']))->fetchField(), 1, t('Session record inserted.'));
$this->assertEqual(db_query("SELECT COUNT(*) FROM {sessions} WHERE uid = :uid AND sid = :sid AND timestamp = :timestamp", array(':uid' => $fields['uid'], ':sid' => $fields['sid'], ':timestamp' => $fields['timestamp']))->fetchField(), 1, 'Session record inserted.');
}
}
......@@ -47,12 +47,12 @@ function testUserEdit() {
$edit['pass[pass1]'] = '';
$edit['pass[pass2]'] = $this->randomName();
$this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
$this->assertText(t("The specified passwords do not match."), t('Typing mismatched passwords displays an error message.'));
$this->assertText(t("The specified passwords do not match."), 'Typing mismatched passwords displays an error message.');
$edit['pass[pass1]'] = $this->randomName();
$edit['pass[pass2]'] = '';
$this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
$this->assertText(t("The specified passwords do not match."), t('Typing mismatched passwords displays an error message.'));
$this->assertText(t("The specified passwords do not match."), 'Typing mismatched passwords displays an error message.');
// Test that the error message appears when attempting to change the mail or
// pass without the current password.
......
......@@ -40,12 +40,12 @@ function setUp() {
* Test label callback.
*/
function testLabelCallback() {
$this->assertEqual($this->account->label(), $this->account->name, t('The username should be used as label'));
$this->assertEqual($this->account->label(), $this->account->name, 'The username should be used as label');
// Setup a random anonymous name to be sure the name is used.
$name = $this->randomName();
config('user.settings')->set('anonymous', $name)->save();
$this->assertEqual($this->anonymous->label(), $name, t('The variable anonymous should be used for name of uid 0'));
$this->assertEqual($this->anonymous->label(), $name, 'The variable anonymous should be used for name of uid 0');
}
/**
......@@ -53,6 +53,6 @@ function testLabelCallback() {
*/
function testUriCallback() {
$uri = $this->account->uri();
$this->assertEqual('user/' . $this->account->uid, $uri['path'], t('Correct user URI.'));
$this->assertEqual('user/' . $this->account->uid, $uri['path'], 'Correct user URI.');
}
}
......@@ -48,20 +48,20 @@ function testLocalUserCreation() {
'predefined_langcode' => 'fr',
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
$this->assertText('French', t('Language added successfully.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertText('French', 'Language added successfully.');
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Set language negotiation.
$edit = array(
'language_interface[enabled][language-url]' => TRUE,
);
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
$this->assertText(t('Language negotiation configuration saved.'), t('Set language negotiation.'));
$this->assertText(t('Language negotiation configuration saved.'), 'Set language negotiation.');
// Check if the language selector is available on admin/people/create and
// set to the currently active language.
$this->drupalGet($langcode . '/admin/people/create');
$this->assertOptionSelected("edit-preferred-langcode", $langcode, t('Global language set in the language selector.'));
$this->assertOptionSelected("edit-preferred-langcode", $langcode, 'Global language set in the language selector.');
// Create a user with the admin/people/create form and check if the correct
// language is set.
......@@ -76,14 +76,14 @@ function testLocalUserCreation() {
$this->drupalPost($langcode . '/admin/people/create', $edit, t('Create new account'));
$user = user_load_by_name($username);
$this->assertEqual($user->preferred_langcode, $langcode, t('New user has correct preferred language set.'));
$this->assertEqual($user->langcode, $langcode, t('New user has correct profile language set.'));
$this->assertEqual($user->preferred_langcode, $langcode, 'New user has correct preferred language set.');
$this->assertEqual($user->langcode, $langcode, 'New user has correct profile language set.');
// Register a new user and check if the language selector is hidden.
$this->drupalLogout();
$this->drupalGet($langcode . '/user/register');
$this->assertNoFieldByName('language[fr]', t('Language selector is not accessible.'));
$this->assertNoFieldByName('language[fr]', 'Language selector is not accessible.');
$username = $this->randomName(10);
$edit = array(
......@@ -94,8 +94,8 @@ function testLocalUserCreation() {
$this->drupalPost($langcode . '/user/register', $edit, t('Create new account'));
$user = user_load_by_name($username);
$this->assertEqual($user->preferred_langcode, $langcode, t('New user has correct preferred language set.'));
$this->assertEqual($user->langcode, $langcode, t('New user has correct profile language set.'));
$this->assertEqual($user->preferred_langcode, $langcode, 'New user has correct preferred language set.');
$this->assertEqual($user->langcode, $langcode, 'New user has correct profile language set.');
// Test if the admin can use the language selector and if the
// correct language is was saved.
......@@ -103,7 +103,7 @@ function testLocalUserCreation() {
$this->drupalLogin($admin_user);
$this->drupalGet($user_edit);
$this->assertOptionSelected("edit-preferred-langcode", $langcode, t('Language selector is accessible and correct language is selected.'));
$this->assertOptionSelected("edit-preferred-langcode", $langcode, 'Language selector is accessible and correct language is selected.');
// Set pass_raw so we can login the new user.
$user->pass_raw = $this->randomName(10);
......@@ -116,6 +116,6 @@ function testLocalUserCreation() {
$this->drupalLogin($user);
$this->drupalGet($user_edit);
$this->assertOptionSelected("edit-preferred-langcode", $langcode, t('Language selector is accessible and correct language is selected.'));
$this->assertOptionSelected("edit-preferred-langcode", $langcode, 'Language selector is accessible and correct language is selected.');
}
}
......@@ -60,18 +60,18 @@ function testUserLanguageConfiguration() {
$path = 'user/' . $web_user->uid . '/edit';
$this->drupalGet($path);
// Ensure language settings fieldset is available.
$this->assertText(t('Language'), t('Language selector available.'));
$this->assertText(t('Language'), 'Language selector available.');
// Ensure custom language is present.
$this->assertText($name, t('Language present on form.'));
$this->assertText($name, 'Language present on form.');
// Switch to our custom language.
$edit = array(
'preferred_langcode' => $langcode,
);
$this->drupalPost($path, $edit, t('Save'));
// Ensure form was submitted successfully.
$this->assertText(t('The changes have been saved.'), t('Changes were saved.'));
$this->assertText(t('The changes have been saved.'), 'Changes were saved.');
// Check if language was changed.
$this->assertOptionSelected('edit-preferred-langcode', $langcode, t('Default language successfully updated.'));
$this->assertOptionSelected('edit-preferred-langcode', $langcode, 'Default language successfully updated.');
$this->drupalLogout();
}
......
......@@ -138,7 +138,7 @@ function assertFailedLogin($account, $flood_trigger = NULL) {
'pass' => $account->pass_raw,
);
$this->drupalPost('user', $edit, t('Log in'));
$this->assertNoFieldByXPath("//input[@name='pass' and @value!='']", NULL, t('Password value attribute is blank.'));
$this->assertNoFieldByXPath("//input[@name='pass' and @value!='']", NULL, 'Password value attribute is blank.');
if (isset($flood_trigger)) {
if ($flood_trigger == 'user') {
$this->assertRaw(format_plural(config('user.flood')->get('user_limit'), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or <a href="@url">request a new password</a>.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or <a href="@url">request a new password</a>.', array('@url' => url('user/password'))));
......
......@@ -41,24 +41,24 @@ function testUserPermissionChanges() {
$account = $this->admin_user;
// Add a permission.
$this->assertFalse(user_access('administer nodes', $account), t('User does not have "administer nodes" permission.'));
$this->assertFalse(user_access('administer nodes', $account), 'User does not have "administer nodes" permission.');
$edit = array();
$edit[$rid . '[administer nodes]'] = TRUE;
$this->drupalPost('admin/people/permissions', $edit, t('Save permissions'));
$this->assertText(t('The changes have been saved.'), t('Successful save message displayed.'));
$this->assertText(t('The changes have been saved.'), 'Successful save message displayed.');
drupal_static_reset('user_access');
drupal_static_reset('user_role_permissions');
$this->assertTrue(user_access('administer nodes', $account), t('User now has "administer nodes" permission.'));
$this->assertTrue(user_access('administer nodes', $account), 'User now has "administer nodes" permission.');
// Remove a permission.
$this->assertTrue(user_access('access user profiles', $account), t('User has "access user profiles" permission.'));
$this->assertTrue(user_access('access user profiles', $account), 'User has "access user profiles" permission.');
$edit = array();
$edit[$rid . '[access user profiles]'] = FALSE;
$this->drupalPost('admin/people/permissions', $edit, t('Save permissions'));
$this->assertText(t('The changes have been saved.'), t('Successful save message displayed.'));
$this->assertText(t('The changes have been saved.'), 'Successful save message displayed.');
drupal_static_reset('user_access');
drupal_static_reset('user_role_permissions');
$this->assertFalse(user_access('access user profiles', $account), t('User no longer has "access user profiles" permission.'));
$this->assertFalse(user_access('access user profiles', $account), 'User no longer has "access user profiles" permission.');
}
/**
......@@ -80,7 +80,7 @@ function testAdministratorRole() {
// Aggregator depends on file module, enable that as well.
$edit['modules[Core][file][enable]'] = TRUE;
$this->drupalPost('admin/modules', $edit, t('Save configuration'));
$this->assertTrue(user_access('administer news feeds', $this->admin_user), t('The permission was automatically assigned to the administrator role'));
$this->assertTrue(user_access('administer news feeds', $this->admin_user), 'The permission was automatically assigned to the administrator role');
}
/**
......@@ -91,9 +91,9 @@ function testUserRoleChangePermissions() {
$account = $this->admin_user;
// Verify current permissions.
$this->assertFalse(user_access('administer nodes', $account), t('User does not have "administer nodes" permission.'));
$this->assertTrue(user_access('access user profiles', $account), t('User has "access user profiles" permission.'));
$this->assertTrue(user_access('administer site configuration', $account), t('User has "administer site configuration" permission.'));
$this->assertFalse(user_access('administer nodes', $account), 'User does not have "administer nodes" permission.');
$this->assertTrue(user_access('access user profiles', $account), 'User has "access user profiles" permission.');
$this->assertTrue(user_access('administer site configuration', $account), 'User has "administer site configuration" permission.');
// Change permissions.
$permissions = array(
......@@ -103,8 +103,8 @@ function testUserRoleChangePermissions() {
user_role_change_permissions($rid, $permissions);
// Verify proper permission changes.
$this->assertTrue(user_access('administer nodes', $account), t('User now has "administer nodes" permission.'));
$this->assertFalse(user_access('access user profiles', $account), t('User no longer has "access user profiles" permission.'));
$this->assertTrue(user_access('administer site configuration', $account), t('User still has "administer site configuration" permission.'));
$this->assertTrue(user_access('administer nodes', $account), 'User now has "administer nodes" permission.');
$this->assertFalse(user_access('access user profiles', $account), 'User no longer has "access user profiles" permission.');
$this->assertTrue(user_access('administer site configuration', $account), 'User still has "administer site configuration" permission.');
}
}
......@@ -61,7 +61,7 @@ function testNoPicture() {
// Try to upload a file that is not an image for the user picture.
$not_an_image = current($this->drupalGetTestFiles('html'));
$this->saveUserPicture($not_an_image);
$this->assertRaw(t('Only JPEG, PNG and GIF images are allowed.'), t('Non-image files are not accepted.'));
$this->assertRaw(t('Only JPEG, PNG and GIF images are allowed.'), 'Non-image files are not accepted.');
}
/**
......@@ -87,13 +87,13 @@ function testWithGDinvalidDimension() {
// Check that the image was resized and is being displayed on the
// user's profile page.
$text = t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array('%dimensions' => $test_dim));
$this->assertRaw($text, t('Image was resized.'));
$this->assertRaw($text, 'Image was resized.');
$alt = t("@user's picture", array('@user' => user_format_name($this->user)));
$style = variable_get('user_picture_style', '');
$this->assertRaw(image_style_url($style, $pic_path), t("Image is displayed in user's edit page"));
$this->assertRaw(image_style_url($style, $pic_path), "Image is displayed in user's edit page");
// Check if file is located in proper directory.
$this->assertTrue(is_file($pic_path), t("File is located in proper directory"));
$this->assertTrue(is_file($pic_path), 'File is located in proper directory.');
}
}
......@@ -124,12 +124,12 @@ function testWithGDinvalidSize() {
// Test that the upload failed and that the correct reason was cited.
$text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename));
$this->assertRaw($text, t('Upload failed.'));
$this->assertRaw($text, 'Upload failed.');
$text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->uri)), '%maxsize' => format_size($test_size * 1024)));
$this->assertRaw($text, t('File size cited as reason for failure.'));
$this->assertRaw($text, 'File size cited as reason for failure.');
// Check if file is not uploaded.
$this->assertFalse(is_file($pic_path), t('File was not uploaded.'));
$this->assertFalse(is_file($pic_path), 'File was not uploaded.');
}
}
......@@ -156,12 +156,12 @@ function testWithoutGDinvalidDimension() {
// Test that the upload failed and that the correct reason was cited.
$text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename));
$this->assertRaw($text, t('Upload failed.'));
$this->assertRaw($text, 'Upload failed.');
$text = t('The image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => $test_dim));
$this->assertRaw($text, t('Checking response on invalid image (dimensions).'));
$this->assertRaw($text, 'Checking response on invalid image (dimensions).');
// Check if file is not uploaded.
$this->assertFalse(is_file($pic_path), t('File was not uploaded.'));
$this->assertFalse(is_file($pic_path), 'File was not uploaded.');
}
}
......@@ -189,12 +189,12 @@ function testWithoutGDinvalidSize() {
// Test that the upload failed and that the correct reason was cited.
$text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename));
$this->assertRaw($text, t('Upload failed.'));
$this->assertRaw($text, 'Upload failed.');
$text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->uri)), '%maxsize' => format_size($test_size * 1024)));
$this->assertRaw($text, t('File size cited as reason for failure.'));
$this->assertRaw($text, 'File size cited as reason for failure.');
// Check if file is not uploaded.
$this->assertFalse(is_file($pic_path), t('File was not uploaded.'));
$this->assertFalse(is_file($pic_path), 'File was not uploaded.');
}
}
......@@ -220,17 +220,17 @@ function testPictureIsValid() {
// Check if image is displayed in user's profile page.
$this->drupalGet('user');
$this->assertRaw(file_uri_target($pic_path), t("Image is displayed in user's profile page"));
$this->assertRaw(file_uri_target($pic_path), "Image is displayed in user's profile page.");
// Check if file is located in proper directory.
$this->assertTrue(is_file($pic_path), t('File is located in proper directory'));
$this->assertTrue(is_file($pic_path), 'File is located in proper directory.');
// Set new picture dimensions.
$test_dim = ($info['width'] + 5) . 'x' . ($info['height'] + 5);
variable_set('user_picture_dimensions', $test_dim);
$pic_path2 = $this->saveUserPicture($image);
$this->assertNotEqual($pic_path, $pic_path2, t('Filename of second picture is different.'));
$this->assertNotEqual($pic_path, $pic_path2, 'Filename of second picture is different.');
}
}
......@@ -250,8 +250,8 @@ function testExternalPicture() {
// Get the user picture image via xpath.
$elements = $this->xpath('//div[@class="user-picture"]/img');
$this->assertEqual(count($elements), 1, t("There is exactly one user picture on the user's profile page"));
$this->assertEqual($pic_path, (string) $elements[0]['src'], t("User picture source is correct: " . $pic_path . " " . print_r($elements, TRUE)));
$this->assertEqual(count($elements), 1, "There is exactly one user picture on the user's profile page.");
$this->assertEqual($pic_path, (string) $elements[0]['src'], format_string("User picture source is correct: %path %elements.", array('%path' => $pic_path, '%elements' => print_r($elements, TRUE))));
}
/**
......
......@@ -39,29 +39,29 @@ function testRoleAdministration() {
$role_name = '123';
$edit = array('role[name]' => $role_name, 'role[rid]' => $role_name);
$this->drupalPost('admin/people/roles', $edit, t('Add role'));
$this->assertText(t('The role has been added.'), t('The role has been added.'));
$this->assertText(t('The role has been added.'), 'The role has been added.');
$role = user_role_load($role_name);
$this->assertTrue(is_object($role), t('The role was successfully retrieved from the database.'));
$this->assertTrue(is_object($role), 'The role was successfully retrieved from the database.');
// Try adding a duplicate role.
$this->drupalPost(NULL, $edit, t('Add role'));
$this->assertRaw(t('The machine-readable name is already in use. It must be unique.'), t('Duplicate role warning displayed.'));
$this->assertRaw(t('The machine-readable name is already in use. It must be unique.'), 'Duplicate role warning displayed.');
// Test renaming a role.
$old_name = $role_name;
$role_name = '456';
$edit = array('role[name]' => $role_name);
$this->drupalPost("admin/people/roles/edit/{$role->rid}", $edit, t('Save role'));
$this->assertText(t('The role has been renamed.'), t('The role has been renamed.'));
$this->assertText(t('The role has been renamed.'), 'The role has been renamed.');
$new_role = user_role_load($old_name);
$this->assertEqual($new_role->name, $role_name, 'The role name has been successfully changed.');
// Test deleting a role.
$this->drupalPost("admin/people/roles/edit/{$role->rid}", NULL, t('Delete role'));
$this->drupalPost(NULL, NULL, t('Delete'));
$this->assertText(t('The role has been deleted.'), t('The role has been deleted'));
$this->assertNoLinkByHref("admin/people/roles/edit/{$role->rid}", t('Role edit link removed.'));
$this->assertFalse(user_role_load($role_name), t('A deleted role can no longer be loaded.'));
$this->assertText(t('The role has been deleted.'), 'The role has been deleted');
$this->assertNoLinkByHref("admin/people/roles/edit/{$role->rid}", 'Role edit link removed.');
$this->assertFalse(user_role_load($role_name), 'A deleted role can no longer be loaded.');
// Make sure that the system-defined roles can be edited via the user
// interface.
......@@ -87,11 +87,11 @@ function testRoleWeightChange() {
// Change the role weight and submit the form.
$edit = array('roles['. $rid .'][weight]' => $old_weight + 1);
$this->drupalPost('admin/people/roles', $edit, t('Save order'));
$this->assertText(t('The role settings have been updated.'), t('The role settings form submitted successfully.'));
$this->assertText(t('The role settings have been updated.'), 'The role settings form submitted successfully.');
// Retrieve the saved role and compare its weight.
$role = user_role_load($rid);
$new_weight = $role->weight;
$this->assertTrue(($old_weight + 1) == $new_weight, t('Role weight updated successfully.'));
$this->assertTrue(($old_weight + 1) == $new_weight, 'Role weight updated successfully.');
}
}
......@@ -17,9 +17,9 @@ class UserRolesAssignmentTest extends WebTestBase {
public static function getInfo() {
return array(
'name' => t('Role assignment'),
'description' => t('Tests that users can be assigned and unassigned roles.'),
'group' => t('User')
'name' => 'Role assignment',
'description' => 'Tests that users can be assigned and unassigned roles.',
'group' => 'User'
);
}
......@@ -40,13 +40,13 @@ function testAssignAndRemoveRole() {
// Assign the role to the user.
$this->drupalPost('user/' . $account->uid . '/edit', array("roles[$rid]" => $rid), t('Save'));
$this->assertText(t('The changes have been saved.'));
$this->assertFieldChecked('edit-roles-' . $rid, t('Role is assigned.'));
$this->assertFieldChecked('edit-roles-' . $rid, 'Role is assigned.');
$this->userLoadAndCheckRoleAssigned($account, $rid);
// Remove the role from the user.
$this->drupalPost('user/' . $account->uid . '/edit', array("roles[$rid]" => FALSE), t('Save'));
$this->assertText(t('The changes have been saved.'));
$this->assertNoFieldChecked('edit-roles-' . $rid, t('Role is removed from user.'));
$this->assertNoFieldChecked('edit-roles-' . $rid, 'Role is removed from user.');
$this->userLoadAndCheckRoleAssigned($account, $rid, FALSE);
}
......@@ -70,13 +70,13 @@ function testCreateUserWithRole() {
$account = user_load_by_name($edit['name']);
$this->drupalGet('user/' . $account->uid . '/edit');
$this->assertFieldChecked('edit-roles-' . $rid, t('Role is assigned.'));
$this->assertFieldChecked('edit-roles-' . $rid, 'Role is assigned.');
$this->userLoadAndCheckRoleAssigned($account, $rid);
// Remove the role again.
$this->drupalPost('user/' . $account->uid . '/edit', array("roles[$rid]" => FALSE), t('Save'));
$this->assertText(t('The changes have been saved.'));
$this->assertNoFieldChecked('edit-roles-' . $rid, t('Role is removed from user.'));
$this->assertNoFieldChecked('edit-roles-' . $rid, 'Role is removed from user.');
$this->userLoadAndCheckRoleAssigned($account, $rid, FALSE);
}
......@@ -94,10 +94,10 @@ function testCreateUserWithRole() {
private function userLoadAndCheckRoleAssigned($account, $rid, $is_assigned = TRUE) {
$account = user_load($account->uid, TRUE);
if ($is_assigned) {
$this->assertTrue(array_key_exists($rid, $account->roles), t('The role is present in the user object.'));
$this->assertTrue(array_key_exists($rid, $account->roles), 'The role is present in the user object.');
}
else {
$this->assertFalse(array_key_exists($rid, $account->roles), t('The role is not present in the user object.'));
$this->assertFalse(array_key_exists($rid, $account->roles), 'The role is not present in the user object.');
}
}
}
......@@ -44,9 +44,9 @@ function testUserImport() {
// Test if created user exists.
$user_by_uid = user_load($test_uid);
$this->assertTrue($user_by_uid, t('Loading user by uid.'));
$this->assertTrue($user_by_uid, 'Loading user by uid.');
$user_by_name = user_load_by_name($test_name);
$this->assertTrue($user_by_name, t('Loading user by name.'));
$this->assertTrue($user_by_name, 'Loading user by name.');
}
}
......@@ -46,25 +46,25 @@ function testUserTimeZone() {
// Confirm date format and time zone.
$this->drupalGet("node/$node1->nid");
$this->assertText('2007-03-09 21:00 PST', t('Date should be PST.'));
$this->assertText('2007-03-09 21:00 PST', 'Date should be PST.');
$this->drupalGet("node/$node2->nid");
$this->assertText('2007-03-11 01:00 PST', t('Date should be PST.'));
$this->assertText('2007-03-11 01:00 PST', 'Date should be PST.');
$this->drupalGet("node/$node3->nid");
$this->assertText('2007-03-20 21:00 PDT', t('Date should be PDT.'));
$this->assertText('2007-03-20 21:00 PDT', 'Date should be PDT.');
// Change user time zone to Santiago time.
$edit = array();
$edit['mail'] = $web_user->mail;
$edit['timezone'] = 'America/Santiago';
$this->drupalPost("user/$web_user->uid/edit", $edit, t('Save'));
$this->assertText(t('The changes have been saved.'), t('Time zone changed to Santiago time.'));
$this->assertText(t('The changes have been saved.'), 'Time zone changed to Santiago time.');
// Confirm date format and time zone.
$this->drupalGet("node/$node1->nid");
$this->assertText('2007-03-10 02:00 CLST', t('Date should be Chile summer time; five hours ahead of PST.'));
$this->assertText('2007-03-10 02:00 CLST', 'Date should be Chile summer time; five hours ahead of PST.');
$this->drupalGet("node/$node2->nid");
$this->assertText('2007-03-11 05:00 CLT', t('Date should be Chile time; four hours ahead of PST'));
$this->assertText('2007-03-11 05:00 CLT', 'Date should be Chile time; four hours ahead of PST');
$this->drupalGet("node/$node3->nid");
$this->assertText('2007-03-21 00:00 CLT', t('Date should be Chile time; three hours ahead of PDT.'));
$this->assertText('2007-03-21 00:00 CLT', 'Date should be Chile time; three hours ahead of PDT.');
}
}
......@@ -72,11 +72,11 @@ function testUserTokenReplacement() {
$tests['[current-user:name]'] = check_plain(user_format_name($global_account));
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.'));
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('user' => $account), array('langcode' => $language_interface->langcode));
$this->assertEqual($output, $expected, t('Sanitized user token %token replaced.', array('%token' => $input)));
$this->assertEqual($output, $expected, format_string('Sanitized user token %token replaced.', array('%token' => $input)));
}