commit 0330815a219f0523249158168d2fd3b5a1ae2b7b
Author: Lee Rowlands <lee.rowlands@previousnext.com.au>
Date:   Thu Aug 23 06:07:14 2012 +1000

    patch-fail

diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/ElementsVerticalTabsTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/ElementsVerticalTabsTest.php
index 9c16ec3..0248f32 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/ElementsVerticalTabsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/ElementsVerticalTabsTest.php
@@ -29,6 +29,14 @@ class ElementsVerticalTabsTest extends WebTestBase {
     );
   }
 
+  function setUp() {
+    parent::setUp();
+
+    $this->admin_user = $this->drupalCreateUser(array('access vertical_tab_test tabs'));
+    $this->web_user = $this->drupalCreateUser();
+    $this->drupalLogin($this->admin_user);
+  }
+
   /**
    * Ensures that vertical-tabs.js is included before collapse.js.
    *
@@ -40,4 +48,21 @@ class ElementsVerticalTabsTest extends WebTestBase {
     $position2 = strpos($this->content, 'core/misc/collapse.js');
     $this->assertTrue($position1 !== FALSE && $position2 !== FALSE && $position1 < $position2, t('vertical-tabs.js is included before collapse.js'));
   }
+
+  /**
+   * Ensures that the vertical-tabs wrapper markup is not shown if the user does
+   * not have access to any of the tabs.
+   */
+  function testWrapperNotShownWhenEmpty() {
+    // Test admin user can see vertical tabs and wrapper.
+    $this->drupalGet('form_test/vertical-tabs');
+    $wrapper = $this->xpath("//div[@class='vertical-tabs-panes']");
+    $this->assertTrue(isset($wrapper[0]), 'Vertical tab panes found.');
+
+    // Test wrapper markup not present for non-privileged web user.
+    $this->drupalLogin($this->web_user);
+    $this->drupalGet('form_test/vertical-tabs');
+    $wrapper = $this->xpath("//div[@class='vertical-tabs-panes']");
+    $this->assertFalse(isset($wrapper[0]), 'Vertical tab wrappers are not displayed to unprivileged users.');
+  }
 }
diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module
index 44fc0eb..670def5 100644
--- a/core/modules/system/tests/modules/form_test/form_test.module
+++ b/core/modules/system/tests/modules/form_test/form_test.module
@@ -290,6 +290,19 @@ function form_test_menu() {
   return $items;
 }
 
+
+/**
+ * Implements hook_permission().
+ */
+function form_test_permission() {
+  $perms = array(
+    'access vertical_tab_test tabs' => array(
+      'title' => t('Access vertical_tab_test tabs'),
+    ),
+  );
+  return $perms;
+}
+
 /**
  * Form submit handler to return form values as JSON.
  */
@@ -759,6 +772,7 @@ function _form_test_vertical_tabs_form($form, &$form_state) {
     '#title' => t('Tab 1'),
     '#collapsible' => TRUE,
     '#group' => 'vertical_tabs',
+    '#access' => user_access('access vertical_tab_test tabs')
   );
   $form['tab1']['field1'] = array(
     '#title' => t('Field 1'),
@@ -769,6 +783,7 @@ function _form_test_vertical_tabs_form($form, &$form_state) {
     '#title' => t('Tab 2'),
     '#collapsible' => TRUE,
     '#group' => 'vertical_tabs',
+    '#access' => user_access('access vertical_tab_test tabs')
   );
   $form['tab2']['field2'] = array(
     '#title' => t('Field 2'),
