From ca89559273d37e0f8da1cbfce6e649ce27caf54f Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Tue, 21 Dec 2010 21:00:17 +0000 Subject: #954804 follow-up by effulgentsia: Fix bugs related to library weighting. --- modules/simpletest/tests/form.test | 30 ++++++++++++++++++++++++ modules/simpletest/tests/form_test.module | 38 +++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) (limited to 'modules/simpletest/tests') diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test index 6a7f26c3d..3debf4042 100644 --- a/modules/simpletest/tests/form.test +++ b/modules/simpletest/tests/form.test @@ -834,6 +834,36 @@ class FormsElementsTableSelectFunctionalTest extends DrupalWebTestCase { } +/** + * Test the vertical_tabs form element for expected behavior. + */ +class FormsElementsVerticalTabsFunctionalTest extends DrupalWebTestCase { + + public static function getInfo() { + return array( + 'name' => 'Vertical tabs form element type test', + 'description' => 'Test the vertical_tabs element for expected behavior', + 'group' => 'Form API', + ); + } + + function setUp() { + parent::setUp('form_test'); + } + + /** + * Ensures that vertical-tabs.js is included before collapse.js. + * + * Otherwise, collapse.js adds "SHOW" or "HIDE" labels to the tabs. + */ + function testJavaScriptOrdering() { + $this->drupalGet('form_test/vertical-tabs'); + $position1 = strpos($this->content, 'misc/vertical-tabs.js'); + $position2 = strpos($this->content, 'misc/collapse.js'); + $this->assertTrue($position1 !== FALSE && $position2 !== FALSE && $position1 < $position2, t('vertical-tabs.js is included before collapse.js')); + } +} + /** * Test the form storage on a multistep form. * diff --git a/modules/simpletest/tests/form_test.module b/modules/simpletest/tests/form_test.module index 142debf47..a816caab5 100644 --- a/modules/simpletest/tests/form_test.module +++ b/modules/simpletest/tests/form_test.module @@ -61,6 +61,14 @@ function form_test_menu() { 'type' => MENU_CALLBACK, ); + $items['form_test/vertical-tabs'] = array( + 'title' => 'Vertical tabs tests', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('_form_test_vertical_tabs_form'), + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + $items['form_test/form-storage'] = array( 'title' => 'Form storage test', 'page callback' => 'drupal_get_form', @@ -537,6 +545,36 @@ function _form_test_tableselect_js_select_form($form, $form_state, $action) { return _form_test_tableselect_form_builder($form, $form_state, $options); } +/** + * Tests functionality of vertical tabs. + */ +function _form_test_vertical_tabs_form($form, &$form_state) { + $form['vertical_tabs'] = array( + '#type' => 'vertical_tabs', + ); + $form['tab1'] = array( + '#type' => 'fieldset', + '#title' => t('Tab 1'), + '#collapsible' => TRUE, + '#group' => 'vertical_tabs', + ); + $form['tab1']['field1'] = array( + '#title' => t('Field 1'), + '#type' => 'textfield', + ); + $form['tab2'] = array( + '#type' => 'fieldset', + '#title' => t('Tab 2'), + '#collapsible' => TRUE, + '#group' => 'vertical_tabs', + ); + $form['tab2']['field2'] = array( + '#title' => t('Field 2'), + '#type' => 'textfield', + ); + return $form; +} + /** * A multistep form for testing the form storage. * -- cgit v1.2.3