From 9ef398004371705191985cace78c0cdbef17c66e Mon Sep 17 00:00:00 2001
From: M Parker <mparker17@536298.no-reply.drupal.org>
Date: Fri, 4 Sep 2015 11:43:21 -0400
Subject: [PATCH] 2563339-2

---
 modules/simpletest/tests/form.test        |  8 +++++++
 modules/simpletest/tests/form_test.module | 40 +++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test
index 0bf6c8c..dda96c5 100644
--- a/modules/simpletest/tests/form.test
+++ b/modules/simpletest/tests/form.test
@@ -1064,6 +1064,14 @@ class FormsElementsVerticalTabsFunctionalTest extends DrupalWebTestCase {
     $position2 = strpos($this->content, 'misc/collapse.js');
     $this->assertTrue($position1 !== FALSE && $position2 !== FALSE && $position1 < $position2, 'vertical-tabs.js is included before collapse.js');
   }
+  
+  function testTabsShowForChildAndGroupWithoutWeight() {
+    // Tests that we can see fieldsets which are BOTH child elements of the
+    // vertical_tabs form element AND have a #group set, but not a #weight.
+    $this->drupalGet('form_test/vertical-tabs-4');
+    $tab2 = $this->xpath("//div[@class='vertical-tabs-panes']/fieldset[@id='edit-tab2']");
+    $this->assertTrue(isset($tab2[0]), 'Child with #group found.');
+  }
 }
 
 /**
diff --git a/modules/simpletest/tests/form_test.module b/modules/simpletest/tests/form_test.module
index 602b409..75e7e0d 100644
--- a/modules/simpletest/tests/form_test.module
+++ b/modules/simpletest/tests/form_test.module
@@ -82,6 +82,14 @@ function form_test_menu() {
     'type' => MENU_CALLBACK,
   );
 
+  $items['form_test/vertical-tabs-4'] = array(
+    'title' => 'Vertical tabs tests',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('_form_test_vertical_tabs_4_form'),
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
+
   $items['form_test/form-storage'] = array(
     'title' => 'Form storage test',
     'page callback' => 'drupal_get_form',
@@ -698,6 +706,38 @@ function _form_test_vertical_tabs_form($form, &$form_state) {
 }
 
 /**
+ * Tests functionality of vertical tabs - children with an explicit #group.
+ */
+function _form_test_vertical_tabs_4_form($form, &$form_state) {
+  $form['vertical_tabs'] = array(
+    '#type' => 'vertical_tabs',
+  );
+  $form['vertical_tabs']['tab1'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Tab 1'),
+    '#collapsible' => TRUE,
+    '#access' => user_access('access vertical_tab_test tabs'),
+    '#group' => 'vertical_tabs',
+  );
+  $form['vertical_tabs']['tab1']['field1'] = array(
+    '#title' => t('Field 1'),
+    '#type' => 'textfield',
+  );
+  $form['vertical_tabs']['tab2'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Tab 2'),
+    '#collapsible' => TRUE,
+    '#access' => user_access('access vertical_tab_test tabs'),
+    '#group' => 'vertical_tabs',
+  );
+  $form['vertical_tabs']['tab2']['field2'] = array(
+    '#title' => t('Field 2'),
+    '#type' => 'textfield',
+  );
+  return $form;
+}
+
+/**
  * A multistep form for testing the form storage.
  *
  * It uses two steps for editing a virtual "thing". Any changes to it are saved
-- 
2.5.0

