1 field_group.ui.test public GroupUITestCase::createGroup()

Test the creation a group on the post content type.

File

core/modules/field_group/tests/field_group.ui.test, line 24
Test file for Field Group UI.

Class

GroupUITestCase
Test the Field Group UI.

Code

public function createGroup() {

  // Create random group name.
  $this->group_label = $this->randomName(8);
  $this->group_name_input = backdrop_strtolower($this->randomName(8));
  $this->group_name = 'group_' . $this->group_name_input;

  // Setup new group.
  $group = array(
    'fields[_add_new_group][label]' => $this->group_label,
    'fields[_add_new_group][group_name]' => $this->group_name_input,
  );
  // Add new group on the 'Manage fields' page.
  $this->backdropPost('admin/structure/types/manage/post/fields', $group, t('Save'));

  $this->assertRaw(t('New group %label successfully created.', array('%label' => $this->group_label)), t('Group message displayed on screen.'));

  // Test if group is in the $groups array.
  $groups = field_group_info_groups('node', 'post', 'form', TRUE);
  $this->assertTrue(array_key_exists($this->group_name, $groups), t('Group found in groups array'));

  // Add new group on the 'Manage display' page.
  $this->backdropPost('admin/structure/types/manage/post/display/default', $group, t('Save'));
  $this->assertRaw(t('New group %label successfully created.', array('%label' => $this->group_label)), t('Group message displayed on screen.'));

  // Test if group is in the $groups array.
  $groups = field_group_info_groups('node', 'post', 'default', TRUE);
  $this->assertTrue(array_key_exists($this->group_name, $groups), t('Group found in groups array'));
}