You are here

public function BlockGroupTest::testBlockGroupCreation in Block Group 8

Tests creating a block group programmatically.

Throws

\Behat\Mink\Exception\ResponseTextException

\Behat\Mink\Exception\ElementNotFoundException

File

tests/src/Functional/BlockGroupTest.php, line 62

Class

BlockGroupTest
Tests the access of block groups and CRUD.

Namespace

Drupal\Tests\blockgroup\Functional

Code

public function testBlockGroupCreation() {
  $web_user = $this
    ->drupalCreateUser([
    'administer blockgroups',
  ]);
  $this
    ->drupalLogin($web_user);

  // Verify that we can manage entities through the user interface.
  $blockgroup_label = 'group_test';
  $blockgroup_machine_name = 'group_test';
  $this
    ->drupalPostForm('/admin/structure/block_group_content/add', [
    'label' => $blockgroup_label,
    'id' => $blockgroup_machine_name,
  ], $this
    ->t('Save'));

  // Check if the created blockgroup is in the list.
  $this
    ->drupalGet('/admin/structure/block_group_content');
  $this
    ->assertSession()
    ->pageTextContains($blockgroup_machine_name);

  // Verify that "Group test" blockgroup is editable.
  $this
    ->drupalGet('/admin/structure/block_group_content/' . $blockgroup_machine_name);
  $this
    ->assertSession()
    ->fieldExists('label');

  // Verify that "Group test" blockgroup can be deleted.
  $this
    ->drupalPostForm('/admin/structure/block_group_content/' . $blockgroup_machine_name . '/delete', [], $this
    ->t('Delete'));
}