You are here

protected function BlockVisibilityGroupsTestBase::placeBlockInGroupUI in Block Visibility Groups 8

Places a block in a block visibility group through the UI.

Parameters

string $plugin_id: The plugin_id for the plugin instance.

string $group_id: The group id.

string $title: The title for the block.

Return value

string The block ID.

1 call to BlockVisibilityGroupsTestBase::placeBlockInGroupUI()
VisibilityTest::testSingleConditions in src/Tests/VisibilityTest.php

File

src/Tests/BlockVisibilityGroupsTestBase.php, line 63

Class

BlockVisibilityGroupsTestBase

Namespace

Drupal\block_visibility_groups\Tests

Code

protected function placeBlockInGroupUI($plugin_id, $group_id, $title) {

  // Enable a standard block.
  $default_theme = $this
    ->config('system.theme')
    ->get('default');
  $edit = [
    'id' => strtolower($this
      ->randomMachineName(8)),
    'region' => 'sidebar_first',
    'settings[label]' => $title,
    'settings[label_display]' => 1,
  ];
  $block_id = $edit['id'];
  if ($group_id) {
    $edit['visibility[condition_group][block_visibility_group]'] = $group_id;
  }
  $this
    ->drupalGet('admin/structure/block/add/' . $plugin_id . '/' . $default_theme);
  $this
    ->drupalPostForm(NULL, $edit, t('Save block'));
  $this
    ->assertText('The block configuration has been saved.', 'Block was saved');

  // Just for Debug message.
  $this
    ->drupalGet('admin/structure/block/manage/' . $block_id);
  $this
    ->drupalGet('admin/structure/block/block-visibility-group/' . $group_id);
  return $block_id;
}