function GroupDisplayTestCase::testVerticalTabs in Field Group 7
Test the vertical tabs formatter.
File
- tests/
field_group.display.test, line 267 - Test file for fieldgroup display.
Class
- GroupDisplayTestCase
- Group display tests
Code
function testVerticalTabs() {
$data = array(
'label' => 'Tab 1',
'weight' => '1',
'children' => array(
0 => 'field_test',
),
'format_type' => 'tab',
'format_settings' => array(
'label' => 'Tab 1',
'instance_settings' => array(
'classes' => 'test-class',
'description' => '',
),
'formatter' => 'open',
),
);
$first_tab = $this
->createGroup('default', $data);
$first_tab_id = 'edit-' . $first_tab->group_name;
$data = array(
'label' => 'Tab 2',
'weight' => '1',
'children' => array(
0 => 'field_test_2',
),
'format_type' => 'tab',
'format_settings' => array(
'label' => 'Tab 1',
'instance_settings' => array(
'classes' => 'test-class-2',
'description' => 'description of second tab',
),
'formatter' => 'closed',
),
);
$second_tab = $this
->createGroup('default', $data);
$second_tab_id = 'edit-' . $second_tab->group_name;
$data = array(
'label' => 'Tabs',
'weight' => '1',
'children' => array(
0 => $first_tab->group_name,
1 => $second_tab->group_name,
),
'format_type' => 'tabs',
'format_settings' => array(
'label' => 'Tab 1',
'instance_settings' => array(
'classes' => 'test-class-wrapper',
),
),
);
$tabs = $this
->createGroup('default', $data);
$groups = field_group_info_groups('node', 'article', 'default', TRUE);
$this
->drupalGet('node/' . $this->node->nid);
// Test properties.
$this
->assertFieldByXPath("//div[contains(@class, 'test-class-wrapper')]", NULL, t('Test class set on tabs wrapper'));
$this
->assertFieldByXPath("//fieldset[contains(@class, 'test-class-2')]", NULL, t('Test class set on second tab'));
$this
->assertRaw('<div class="fieldset-description">description of second tab</div>', t('Description of tab is shown'));
$this
->assertRaw('class="collapsible collapsed test-class-2', t('Second tab is default collapsed'));
// Test if correctly nested
$this
->assertFieldByXPath("//div[contains(@class, 'test-class-wrapper')]//fieldset[contains(@id, '{$first_tab_id}')]", NULL, 'First tab is displayed as child of the wrapper.');
$this
->assertFieldByXPath("//div[contains(@class, 'test-class-wrapper')]//fieldset[contains(@id, '{$second_tab_id}')]", NULL, 'Second tab is displayed as child of the wrapper.');
}