You are here

function GroupDisplayTestCase::testHorizontalTabs in Field Group 7

Test the horizontal tabs formatter.

File

tests/field_group.display.test, line 193
Test file for fieldgroup display.

Class

GroupDisplayTestCase
Group display tests

Code

function testHorizontalTabs() {
  $data = array(
    'label' => 'Tab 1',
    'weight' => '1',
    'children' => array(
      0 => 'field_test',
    ),
    'format_type' => 'htab',
    'format_settings' => array(
      'label' => 'Tab 1',
      'instance_settings' => array(
        'classes' => 'test-class',
        'description' => '',
      ),
      'formatter' => 'open',
    ),
  );
  $first_tab = $this
    ->createGroup('default', $data);
  $data = array(
    'label' => 'Tab 2',
    'weight' => '1',
    'children' => array(
      0 => 'field_test_2',
    ),
    'format_type' => 'htab',
    '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);
  $data = array(
    'label' => 'Tabs',
    'weight' => '1',
    'children' => array(
      0 => $first_tab->group_name,
      1 => $second_tab->group_name,
    ),
    'format_type' => 'htabs',
    '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(@class, 'test-class')]", NULL, 'First tab is displayed as child of the wrapper.');
  $this
    ->assertFieldByXPath("//div[contains(@class, 'test-class-wrapper')]//fieldset[contains(@class, 'test-class-2')]", NULL, 'Second tab is displayed as child of the wrapper.');
}