You are here

function GroupUITestCase::createGroup in Field Group 7

Same name and namespace in other branches
  1. 7.2 field_group.test \GroupUITestCase::createGroup()

Test the creation a group on the article content type.

2 calls to GroupUITestCase::createGroup()
GroupUITestCase::testCRUDGroup in tests/field_group.ui.test
General CRUD.
GroupUITestCase::testNestField in tests/field_group.ui.test
Nest a field underneath a group.

File

tests/field_group.ui.test, line 32
Test file for fieldgroup UI.

Class

GroupUITestCase
Group UI tests.

Code

function createGroup() {

  // Create random group name.
  $this->group_label = $this
    ->randomName(8);
  $this->group_name_input = drupal_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
    ->drupalPost('admin/structure/types/manage/article/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', 'article', '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
    ->drupalPost('admin/structure/types/manage/article/display', $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', 'article', 'default', TRUE);
  $this
    ->assertTrue(array_key_exists($this->group_name, $groups), t('Group found in groups array'));
}