summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-01-06 11:04:59 +0000
committerDries Buytaert <dries@buytaert.net>2009-01-06 11:04:59 +0000
commitcce322378c7b16258cf088082664ee796c3c8eda (patch)
tree2e285ea0171df2ed8791ab38a6f6e0f1340bb145
parent009d05cbe30af1cc69f50f3fd5cabf49a31f9770 (diff)
downloadbrdo-cce322378c7b16258cf088082664ee796c3c8eda.tar.gz
brdo-cce322378c7b16258cf088082664ee796c3c8eda.tar.bz2
- Patch #353618 by sun: drupalLogin does not update passed-in user object -- improved documentation.
-rw-r--r--modules/simpletest/drupal_web_test_case.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index a453caa7c..f1cb12774 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -736,11 +736,31 @@ class DrupalWebTestCase {
}
/**
- * Logs in a user with the internal browser. If a user is already logged in,
- * then the current user is logged out before logging in the specified user.
+ * Log in a user with the internal browser.
+ *
+ * If a user is already logged in, then the current user is logged out before
+ * logging in the specified user.
+ *
+ * Please note that neither the global $user nor the passed in user object is
+ * populated with data of the logged in user. If you need full access to the
+ * user object after logging in, it must be updated manually. If you also need
+ * access to the plain-text password of the user (set by drupalCreateUser()),
+ * e.g. to login the same user again, then it must be re-assigned manually.
+ * For example:
+ * @code
+ * // Create a user.
+ * $account = $this->drupalCreateUser(array());
+ * $this->drupalLogin($account);
+ * // Load real user object.
+ * $pass_raw = $account->pass_raw;
+ * $account = user_load($account->uid);
+ * $account->pass_raw = $pass_raw;
+ * @endcode
*
* @param $user
* User object representing the user to login.
+ *
+ * @see drupalCreateUser()
*/
protected function drupalLogin(stdClass $user) {
if ($this->isLoggedIn) {