Index: admin_menu.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.inc,v
retrieving revision 1.11.2.20.2.24
diff -u -p -r1.11.2.20.2.24 admin_menu.inc
--- admin_menu.inc	19 Aug 2009 02:13:50 -0000	1.11.2.20.2.24
+++ admin_menu.inc	9 Sep 2009 16:45:59 -0000
@@ -26,6 +26,14 @@ function admin_menu_links_menu($tree) {
     if (isset($data['link']['type']) && $data['link']['type'] == MENU_CALLBACK) {
       continue;
     }
+    // Hide 'Administer' and make child links appear on this level.
+    // @todo Make this configurable.
+    if ($data['link']['router_path'] == 'admin') {
+      if ($data['below']) {
+        $links = array_merge($links, admin_menu_links_menu($data['below']));
+      }
+      continue;
+    }
     // Omit alias lookups.
     $data['link']['localized_options']['alias'] = TRUE;
     // Remove description to prevent mouseover tooltip clashes.
Index: admin_menu.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.module,v
retrieving revision 1.43.2.17.2.26
diff -u -p -r1.43.2.17.2.26 admin_menu.module
--- admin_menu.module	16 Aug 2009 21:51:12 -0000	1.43.2.17.2.26
+++ admin_menu.module	9 Sep 2009 16:49:09 -0000
@@ -89,44 +89,38 @@ function admin_menu_menu() {
  * Implementation of hook_menu_alter().
  */
 function admin_menu_menu_alter(&$items) {
-  // Move all items below admin/* into administration menu.
   foreach ($items as $path => $item) {
-    if (strpos($path, 'admin') === 0) {
-      if (!isset($item['type'])) {
-        $items[$path]['menu_name'] = 'admin_menu';
-      }
-      else {
+    if (!strncmp($path, 'admin/', 6)) {
+      if (isset($item['type'])) {
         // For any reason, content-type menu items are registered individually
         // in Drupal core, but also by CCK. We a) have to copy and re-assign
         // them the proper router path and b) turn their parent items from
         // MENU_CALLBACK into something visible; otherwise, the menu system
         // does not find the parents and relocates child items to the top-level.
         if (strpos($path, 'admin/content/node-type/') === 0) {
-          // Fix router path.
-          $newpath = strtr($path, array('/node-type/' => '/types/'));
-          $items[$newpath] = $items[$path];
-          // Alter item type and visibility.
-          $items[$newpath]['type'] &= ~MENU_CALLBACK;
-          if ($items[$newpath]['type'] === 0) {
-            $items[$newpath]['type'] |= MENU_NORMAL_ITEM;
-          }
+          // Copy item with fixed router path.
+          $newpath = str_replace('/node-type/', '/types/', $path);
+          $items[$newpath] = $item;
           // Use new item from here, but leave old intact to play nice with
           // others.
           $path = $newpath;
-          $item = $items[$newpath];
+          // Turn MENU_CALLBACK items into visible menu items.
+          if ($item['type'] == MENU_CALLBACK) {
+            $items[$path]['type'] = MENU_NORMAL_ITEM;
+          }
         }
+        // Skip invisible MENU_CALLBACKs.
+        if ($item['type'] == MENU_CALLBACK) {
+          continue;
+        }
+        // Trick local tasks and actions into the visible menu tree.
         if ($item['type'] & MENU_IS_LOCAL_TASK) {
-          // Trick this item into the visible menu tree.
           $items[$path]['_visible'] = TRUE;
         }
-        // Skip invisible MENU_CALLBACKs, but make sure that it is not a
-        // MENU_NORMAL_ITEM, which shares the MENU_VISIBLE_IN_BREADCRUMB bit.
-        if ($item['type'] === MENU_CALLBACK) {
-          continue;
-        }
         $items[$path]['menu_name'] = 'admin_menu';
       }
     }
+/*
     // Copy 'Add new content' into admin_menu menu.
     elseif (strpos($path, 'node/add') === 0) {
       $newpath = 'admin/' . $path;
@@ -136,10 +130,11 @@ function admin_menu_menu_alter(&$items) 
         $items[$newpath]['weight'] = -15;
       }
     }
+*/
   }
 
   // Remove 'admin', so children appear on the top-level.
-  $items['admin']['type'] = MENU_CALLBACK;
+  $items['admin']['menu_name'] = 'admin_menu';
   // Remove local tasks on 'admin'.
   $items['admin/by-task']['_visible'] = FALSE;
   $items['admin/by-module']['_visible'] = FALSE;
@@ -156,7 +151,7 @@ function admin_menu_menu_alter(&$items) 
   db_query("UPDATE {menu_links} SET menu_name = 'admin_menu', customized = 0 WHERE router_path = 'admin'");
 
   // Flush client-side caches whenever the menu is rebuilt.
-  module_invoke('admin_menu', 'flush_caches');
+  admin_menu_flush_caches();
 }
 
 /**
Index: tests/admin_menu.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/tests/admin_menu.test,v
retrieving revision 1.1.2.5.2.5
diff -u -p -r1.1.2.5.2.5 admin_menu.test
--- tests/admin_menu.test	22 Jul 2009 20:34:28 -0000	1.1.2.5.2.5
+++ tests/admin_menu.test	8 Sep 2009 19:09:59 -0000
@@ -4,115 +4,114 @@
 /**
  * @file
  * Administration menu functionality tests.
- *
- * Note: When using $this->assertPattern(), be sure to use the 's' modifier for
- * the PCRE pattern, since admin menu's output spans over multiple lines.
  */
 
-
 /**
- * Test menu links depending on user permissions.
+ * Base class for all administration menu web test cases.
  */
-class AdminMenuPermissionsTestCase extends DrupalWebTestCase {
-  public static function getInfo() {
-    return array(
-      'name' => 'Menu link permissions',
-      'description' => 'Verify that menu is displayed according to user permissions.',
-      'group' => 'Administration menu',
-    );
-  }
+class AdminMenuWebTestCase extends DrupalWebTestCase {
 
   function setUp() {
-    parent::setUp('admin_menu');
+    // Enable admin menu module and any other modules.
+    $args = func_get_args();
+    call_user_func_array(array($this, 'parent::setUp'), array_merge(array('admin_menu'), $args));
     // Disable client-side caching.
     variable_set('admin_menu_cache_client', FALSE);
   }
 
   /**
-   * Test that the links are added to the page (no JS testing).
+   * Check that an element exists in HTML markup.
+   *
+   * @param $xpath
+   *   An XPath expression.
+   * @param $message
+   *   The message to display along with the assertion.
+   * @param $group
+   *   The type of assertion - examples are "Browser", "PHP".
+   * @return
+   *   TRUE if the assertion succeeded, FALSE otherwise.
    */
-  function testPermissions() {
-    // Anonymous users should not see the menu.
-    $this->assertNoRaw('<div id="admin-menu">', t('Admin menu not displayed to anonymous.'));
-
-    // Create a new user who can access administration menu, but without the
-    // permission 'display drupal links'.
-    $admin_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'administer nodes', 'access administration menu'));
-    $this->drupalLogin($admin_user);
-
-    // Check that the user can see the admin links, but not the drupal links.
-    $this->assertRaw('<div id="admin-menu">', t('Administration menu is displayed.'));
-    $this->drupalGet('node');
-    $this->assertPattern('@<div id="admin-menu">.*admin/content/node@s', t('Administer content link found.'));
-    $this->assertNoPattern('@<div id="admin-menu">.*http://drupal.org@s', t('Drupal links not found.'));
-    $this->assertNoPattern('@<div id="admin-menu">.*admin/build/contact@s', t('Contact module link not found.'));
+  protected function assertElementByXPath($xpath, $message, $group = 'Other') {
+    return $this->assertTrue($this->xpath($xpath), $message, $group);
+  }
 
-    // Create a new user with the permission 'display drupal links'.
-    $admin_user2 = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'administer nodes', 'access administration menu', 'display drupal links'));
-    $this->drupalLogin($admin_user2);
-    $this->drupalGet('node');
-    $this->assertPattern('@<div id="admin-menu">.*http://drupal.org@s', t('Drupal links found.'));
-    $this->assertNoPattern('@<div id="admin-menu">.*admin/build/contact@s', t('Contact module link not found.'));
+  /**
+   * Check that an element does not exist in HTML markup.
+   *
+   * @param $xpath
+   *   An XPath expression.
+   * @param $message
+   *   The message to display along with the assertion.
+   * @param $group
+   *   The type of assertion - examples are "Browser", "PHP".
+   * @return
+   *   TRUE if the assertion succeeded, FALSE otherwise.
+   */
+  protected function assertNoElementByXPath($xpath, $message, $group = 'Other') {
+    return $this->assertFalse($this->xpath($xpath), $message, $group);
   }
 }
 
 /**
- * Test menu links depending on installed modules.
+ * Test menu links depending on user permissions.
  */
-class AdminMenuModulesTestCase extends DrupalWebTestCase {
+class AdminMenuPermissionsTestCase extends AdminMenuWebTestCase {
   public static function getInfo() {
     return array(
-      'name' => 'Module links',
-      'description' => 'Verify that menu contains links according to enabled modules.',
+      'name' => 'Menu link permissions',
+      'description' => 'Verify that menu is displayed according to user permissions.',
       'group' => 'Administration menu',
     );
   }
 
   function setUp() {
-    parent::setUp('admin_menu', 'contact');
-    // Disable client-side caching.
-    variable_set('admin_menu_cache_client', FALSE);
+    // Additionally enable contact module.
+    parent::setUp('contact');
   }
 
   /**
    * Test that the links are added to the page (no JS testing).
    */
-  function testContactModuleLinks() {
-    // Create a new user without 'administer site-wide contact form' permission.
-    $admin_user = $this->drupalCreateUser(array('access administration pages', 'access administration menu'));
-    $this->drupalLogin($admin_user);
-
-    // Verify that proper links are displayed.
-    $this->assertRaw('<div id="admin-menu">', t('Administration menu is displayed.'));
+  function testPermissions() {
+    // Anonymous users should not see the menu.
     $this->drupalGet('node');
-    $this->assertNoPattern('@<div id="admin-menu">.*admin/build/contact@s', t('Contact module link not found.'));
+    $this->assertNoElementByXPath('//div[@id="admin-menu"]', t('Admin menu not displayed to anonymous.'));
 
-    // Create a new user with 'administer site-wide contact form' permission.
-    $admin_user = $this->drupalCreateUser(array('access administration pages', 'access administration menu', 'administer site-wide contact form'));
+    // Create a new user who can access administration menu, but without the
+    // permission 'display drupal links'.
+    $admin_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'administer nodes', 'access administration menu'));
     $this->drupalLogin($admin_user);
 
-    // Verify that proper links are displayed.
+    // Check that the user can see the admin links, but not the drupal links.
+    $this->assertElementByXPath('//div[@id="admin-menu"]', t('Administration menu is displayed.'));
     $this->drupalGet('node');
-    $this->assertPattern('@<div id="admin-menu">.*admin/build/contact@s', t('Contact module link found.'));
+    $this->assertElementByXPath('//div[@id="admin-menu"]//a[@href="/admin/content/node"]', t('Administer content link found.'));
+    $this->assertNoElementByXPath('//div[@id="admin-menu"]//a[@href="http://drupal.org"]', t('Drupal links not found.'));
+    $this->assertNoElementByXPath('//div[@id="admin-menu"]//a[@href="/admin/build/contact"]', t('Contact module link not found.'));
+
+    // Create a new user with the permission 'display drupal links'.
+    $admin_user2 = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'administer nodes', 'access administration menu', 'display drupal links', 'administer site-wide contact form'));
+    $this->drupalLogin($admin_user2);
+    $this->drupalGet('node');
+    $this->assertElementByXPath('//div[@id="admin-menu"]//a[@href="http://drupal.org"]', t('Drupal links found.'));
+    $this->assertElementByXPath('//div[@id="admin-menu"]//a[@href="/admin/build/contact"]', t('Contact module link found.'));
   }
 }
 
 /**
  * Test contained links in administration menu.
  */
-class AdminMenuLinksTestCase extends DrupalWebTestCase {
+class AdminMenuLinksTestCase extends AdminMenuWebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Menu links',
-      'description' => 'Verify that menu contains proper links.',
+      'description' => 'Verify that admin menu contains proper links.',
       'group' => 'Administration menu',
     );
   }
 
   function setUp() {
-    parent::setUp('admin_menu');
-    // Disable client-side caching.
-    variable_set('admin_menu_cache_client', FALSE);
+    parent::setUp();
 
     // Create and log in a full-blown administrative user.
     $permissions = module_invoke_all('perm');
@@ -137,7 +136,7 @@ class AdminMenuLinksTestCase extends Dru
 
     // Fetch a page.
     $this->drupalGet('node');
-    $this->assertRaw('<div id="admin-menu">', t('Administration menu is displayed.'));
+    $this->assertElementByXPath('//div[@id="admin-menu"]', t('Administration menu is displayed.'));
 
     // Verify that proper links are displayed.
     // We are explicitly NOT using t() here, since the purpose is to test our
