Index: menu_example.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/examples/menu_example/menu_example.module,v
retrieving revision 1.2
diff -u -r1.2 menu_example.module
--- menu_example/menu_example.module	29 May 2010 00:35:49 -0000	1.2
+++ menu_example/menu_example.module	13 Oct 2010 19:51:44 -0000
@@ -374,7 +374,9 @@
  *   menu_router table.
  */
 function menu_example_menu_alter(&$items) {
-  // Change the path 'user/logout' to a Spanish 'user/salir''.
+  // Change the path 'user/logout' to a Spanish 'user/salir''. This change will
+  // prevent the menu "Log out" link to show up. You should go to user/salir
+  // manually to log out the site.
   if (!empty($items['user/logout'])) {
     $items['user/salir'] = $items['user/logout'];
     unset($items['user/logout']);
@@ -382,8 +384,8 @@
 
   // Here we will change the title callback to our own function, changing the
   // 'user' link from the traditional to always being "username's account".
-  if (!empty($items['user/%user_uid_only_optional'])) {
-    $items['user/%user_uid_only_optional']['title callback'] = 'menu_example_user_page_title';
+  if (!empty($items['user/%user'])) {
+    $items['user/%user']['title callback'] = 'menu_example_user_page_title';
   }
 }
 
@@ -404,13 +406,7 @@
  * @param $account
  *   User account related to the visited page.
  */
-function menu_example_user_page_title($uid) {
-  if ($GLOBALS['user']->uid == $uid) {
-    $account = $GLOBALS['user'];
-  }
-  else {
-    $account = user_load($uid);
-  }
+function menu_example_user_page_title($account) {
   return is_object($account) ? t("@name's account", array('@name' => format_username($account))) : '';
 }
 
Index: menu_example.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/examples/menu_example/menu_example.test,v
retrieving revision 1.2
diff -u -r1.2 menu_example.test
--- menu_example/menu_example.test	29 May 2010 00:35:49 -0000	1.2
+++ menu_example/menu_example.test	13 Oct 2010 20:09:42 -0000
@@ -66,12 +66,25 @@
     $this->clickLink(t('Processed Placeholder Arguments'));
     $this->assertText(t('Loaded value was jackpot! default'));
 
-
     // Create a user with permissions to access protected menu entry.
     $web_user = $this->drupalCreateUser(array('access protected menu example'));
-    $this->drupalLogin($web_user);
+
+    // Don't use drupalLogin here, because it will fail looking for the logout
+    // link, changed to user/salir by the menu example module. 
+    $edit = array(
+      'name' => $web_user->name,
+      'pass' => $web_user->pass_raw
+    );
+    $this->drupalPost('user', $edit, t('Log in'));
+    // If a "log out" link appears on the page, it is almost certainly because
+    // the login was successful.
+    $pass = $this->assertLink(t('My account'), 0, t('User %name successfully logged in.', array('%name' => $web_user->name)), t('User login'));
+
     // Check that our title callback changing /user dynamically is working.
-    $this->assertRaw(t("@name&#039;s account", array('@name' => $web_user->name)));
+    // Using &#039; because of the format_username function.
+    $this->assertRaw(t("@name&#039;s account", array('@name' => format_username($web_user))), t('Title successfully changed to account name: %name.', array('%name' => $web_user->name)));
+
+    // Now start testing other menu entries.
     $this->drupalGet('menu_example');
 
     $this->clickLink(t('Permissioned Example'));

