function FieldsetHelperTestCase::testFieldsetHelperSetCollapsibleFieldsetIds in Fieldset helper 6
Test adding fieldset id's to $form array.
File
- ./
fieldset_helper.test, line 64
Class
Code
function testFieldsetHelperSetCollapsibleFieldsetIds() {
// Test form with collapsible fieldset.
$form_id = 'mock-form-with-collapsible-fieldsets';
$form['parent'] = array(
'#type' => 'fieldset',
'#title' => t('Parent fieldset'),
);
$form['parent']['collapsible'] = array(
'#type' => 'fieldset',
'#title' => t('Collapsible fieldset'),
'#collapsible' => TRUE,
);
$form['parent']['collapsed'] = array(
'#type' => 'fieldset',
'#title' => t('Collapsed fieldset'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['parent']['1 with a B@D nam3'] = array(
'#type' => 'fieldset',
'#title' => t('Collapsible fieldset'),
'#collapsible' => TRUE,
);
$has_collapsible_fieldset = _fieldset_helper_set_collapsible_fieldset_ids($form, $form_id);
$this
->assertTrue($has_collapsible_fieldset, t('Form has collapsible fieldsets'));
$this
->assertTrue($form['parent']['collapsible']['#attributes']['id'] == 'fieldset-parent-collapsible', t('Fieldset has id.'));
$this
->assertTrue($form['parent']['1 with a B@D nam3']['#attributes']['id'] == 'fieldset-parent-1-with-a-b-d-nam3', t('Fieldset has id.'));
$this
->assertFalse(isset($form['parent']['#attributes']), t('Fieldset has does not id.'));
// Test form with out collapsible fieldset.
$form_id = 'mock-form-with-out-collapsible-fieldsets';
$form['parent'] = array(
'#type' => 'fieldset',
'#title' => t('Plain fieldset'),
);
$form['parent']['text'] = array(
'#type' => 'textfield',
'#title' => t('Text field'),
);
$has_collapsible_fieldset = _fieldset_helper_set_collapsible_fieldset_ids($form, $form_id);
$this
->assertFalse($has_collapsible_fieldset, t('Form does not have collapsible fieldsets'));
}