diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test index ce3deab..37b76c6 100644 --- a/modules/simpletest/tests/form.test +++ b/modules/simpletest/tests/form.test @@ -1093,19 +1093,26 @@ class FormsElementsVerticalTabsFunctionalTest extends DrupalWebTestCase { * 3. They are children of the wrapper with no #group set for any child. */ function testTabsShowForChildOrGroup() { - // Test we can see a non-child with #group set. + // Tests we can see fieldsets which are not child elements vertical_tabs + // form element, but are placed in the set of vertical tabs because of their + // #group, like $form['email_admin_created'] in user_admin_settings(). $this->drupalGet('form_test/vertical-tabs'); $tab1 = $this->xpath("//div[@class='vertical-tabs-panes']/fieldset[@id='edit-tab1']"); $this->assertTrue(isset($tab1[0]), 'Non-child with #group found.'); - // Test we can see a child with #group set. - $tab3 = $this->xpath("//div[@class='vertical-tabs-panes']/fieldset[@id='edit-tab3']"); - $this->assertTrue(isset($tab3[0]), 'Child with #group found.'); - - // Test we can see children without #group set. + // Tests that we can see fieldsets which are child elements of the + // vertical_tabs form element, and are placed in the set of vertical tabs + // simply because they're child elements. $this->drupalGet('form_test/vertical-tabs-2'); $tab2 = $this->xpath("//div[@class='vertical-tabs-panes']/fieldset[@id='edit-tab2']"); $this->assertTrue(isset($tab2[0]), 'Children with no #group found.'); + + // Tests that we can see fieldsets which are BOTH child elements of the + // vertical_tabs form element AND have their #group set, like + // $form['visibility']['path'] in block_admin_configure(). + $this->drupalGet('form_test/vertical-tabs-3'); + $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 ea204c3..2dbf259 100644 --- a/modules/simpletest/tests/form_test.module +++ b/modules/simpletest/tests/form_test.module @@ -90,6 +90,14 @@ function form_test_menu() { 'type' => MENU_CALLBACK, ); + $items['form_test/vertical-tabs-3'] = array( + 'title' => 'Vertical tabs tests', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('_form_test_vertical_tabs_3_form'), + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + $items['form_test/form-storage'] = array( 'title' => 'Form storage test', 'page callback' => 'drupal_get_form', @@ -688,7 +696,7 @@ function _form_test_tableselect_js_select_form($form, $form_state, $action) { } /** - * Tests functionality of vertical tabs. + * Tests functionality of vertical tabs - non-children with an explicit #group. */ function _form_test_vertical_tabs_form($form, &$form_state) { $form['vertical_tabs'] = array( @@ -716,17 +724,6 @@ function _form_test_vertical_tabs_form($form, &$form_state) { '#title' => t('Field 2'), '#type' => 'textfield', ); - $form['vertical_tabs']['tab3'] = array( - '#type' => 'fieldset', - '#title' => t('Tab 3'), - '#collapsible' => TRUE, - '#group' => 'vertical_tabs', - '#access' => user_access('access vertical_tab_test tabs') - ); - $form['vertical_tabs']['tab3']['field3'] = array( - '#title' => t('Field 3'), - '#type' => 'textfield', - ); return $form; } @@ -761,6 +758,38 @@ function _form_test_vertical_tabs_2_form($form, &$form_state) { } /** + * Tests functionality of vertical tabs - children with an explicit #group. + */ +function _form_test_vertical_tabs_3_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