function DrupalTestCase::drupalLoginUser in SimpleTest 6
Same name and namespace in other branches
- 5 drupal_test_case.php \DrupalTestCase::drupalLoginUser()
Logs in a user with the internal browser
Parameters
object user object with pass_raw property!:
$submit value of submit button on log in form:
42 calls to DrupalTestCase::drupalLoginUser()
- ActionsContentTest::testActionsContent in tests/
content_actions.test - Various tests, all in one function to assure they happen in the right order.
- AddForumTest::testAddForum in tests/
forum_module.test - AddForumTest::testAddForumContainer in tests/
forum_module.test - AddTopicToForum::testAddTopicToContainer in tests/
forum_module.test - AddTopicToForum::testAddTopicToForum in tests/
forum_module.test
File
- ./
drupal_test_case.php, line 419
Class
- DrupalTestCase
- Test case for typical Drupal tests. Extends WebTestCase for comfortable browser usage but also implements all UnitTestCase methods, I wish WebTestCase would do this.
Code
function drupalLoginUser($user = NULL, $submit = 'Log in') {
$this
->drupalGet('user');
// Going to the page retrieves the cookie, as the browser should save it
if ($user === NULL) {
$user = $this
->drupalCreateUserRolePerm();
}
$edit = array(
'name' => $user->name,
'pass' => $user->pass_raw,
);
$this
->drupalPost('user', $edit, $submit);
$this
->assertText($user->name, ' [login] found name: ' . $user->name);
$this
->assertNoText(t('The username %name has been blocked.', array(
'%name' => $user->name,
)), ' [login] not blocked');
$this
->assertNoText(t('The name %name is a reserved username.', array(
'%name' => $user->name,
)), ' [login] not reserved');
return $user;
}