You are here

protected function PageManagerAdminTest::doTestAddBlock in Page Manager 8

Tests adding a block to a variant.

1 call to PageManagerAdminTest::doTestAddBlock()
PageManagerAdminTest::testAdmin in page_manager_ui/src/Tests/PageManagerAdminTest.php
Tests the Page Manager admin UI.

File

page_manager_ui/src/Tests/PageManagerAdminTest.php, line 307
Contains \Drupal\page_manager_ui\Tests\PageManagerAdminTest.

Class

PageManagerAdminTest
Tests the admin UI for page entities.

Namespace

Drupal\page_manager_ui\Tests

Code

protected function doTestAddBlock() {
  $this
    ->drupalGet('admin/structure/page_manager/manage/foo/page_variant__foo-block_display-0__content');

  // Add a block to the variant.
  $this
    ->clickLink('Add new block');

  // Assert that the broken/missing block is not visible.
  $this
    ->assertNoText('Broken/Missing');
  $this
    ->clickLink('User account menu');
  $edit = [
    'region' => 'top',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Add block');
  $this
    ->drupalPostForm(NULL, [], 'Update and save');

  // Test that the block is displayed.
  $this
    ->drupalGet('admin/foo');
  $this
    ->assertResponse(200);
  $elements = $this
    ->xpath('//div[@class="block-region-top"]/nav/ul[@class="menu"]/li/a');
  $this
    ->assertTitle('Example title | Drupal');
  $expected = [
    'My account',
    'Log out',
  ];
  $links = [];
  foreach ($elements as $element) {
    $links[] = (string) $element;
  }
  $this
    ->assertEqual($expected, $links);

  // Check the block label.
  $this
    ->assertRaw('User account menu');
}