You are here

public function ManageDisplayTest::testDeleteGroup in Field Group 8

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/ManageDisplayTest.php \Drupal\Tests\field_group\Functional\ManageDisplayTest::testDeleteGroup()

Delete a group.

File

tests/src/Functional/ManageDisplayTest.php, line 102

Class

ManageDisplayTest
Tests for managing display of entities.

Namespace

Drupal\Tests\field_group\Functional

Code

public function testDeleteGroup() {
  $data = array(
    'format_type' => 'fieldset',
    'label' => 'testing',
  );
  $group = $this
    ->createGroup('node', $this->type, 'form', 'default', $data);
  $this
    ->drupalPostForm('admin/structure/types/manage/' . $this->type . '/form-display/' . $group->group_name . '/delete', array(), 'Delete');
  $this
    ->assertSession()
    ->responseContains(t('The group %label has been deleted from the %type content type.', array(
    '%label' => $group->label,
    '%type' => $this->type,
  )));

  // Test that group is not in the $groups array.
  \Drupal::entityTypeManager()
    ->getStorage('entity_form_display')
    ->resetCache();
  $loaded_group = field_group_load_field_group($group->group_name, 'node', $this->type, 'form', 'default');
  $this
    ->assertNull($loaded_group, 'Group not found after deleting');
  $data = array(
    'format_type' => 'fieldset',
    'label' => 'testing',
  );
  $group = $this
    ->createGroup('node', $this->type, 'view', 'default', $data);
  $this
    ->drupalPostForm('admin/structure/types/manage/' . $this->type . '/display/' . $group->group_name . '/delete', array(), t('Delete'));
  $this
    ->assertRaw(t('The group %label has been deleted from the %type content type.', array(
    '%label' => $group->label,
    '%type' => $this->type,
  )));

  // Test that group is not in the $groups array.
  \Drupal::entityTypeManager()
    ->getStorage('entity_view_display')
    ->resetCache();
  $loaded_group = field_group_load_field_group($group->group_name, 'node', $this->type, 'view', 'default');
  $this
    ->assertNull($loaded_group, 'Group not found after deleting');
}