You are here

protected function PageManagerAdminTest::doTestAddVariant in Page Manager 8

Tests adding a variant.

1 call to PageManagerAdminTest::doTestAddVariant()
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 273
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 doTestAddVariant() {
  $this
    ->drupalGet('admin/structure/page_manager/manage/foo/general');

  // Add a new variant.
  $this
    ->clickLink('Add variant');
  $edit = [
    'variant_plugin_id' => 'block_display',
    'label' => 'First',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Next');

  // Set the page title.
  $edit = [
    'variant_settings[page_title]' => 'Example title',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Next');

  // Finish variant wizard without adding blocks.
  $this
    ->drupalPostForm(NULL, [], 'Finish');

  // Save page to apply variant changes.
  $this
    ->drupalPostForm(NULL, [], 'Update and save');

  // Test that the variant is still used but empty.
  $this
    ->drupalGet('admin/foo');
  $this
    ->assertResponse(200);

  // Tests that the content region has no content at all.
  $elements = $this
    ->xpath('//div[@class=:region]', [
    ':region' => 'region region-content',
  ]);
  $this
    ->assertIdentical(0, $elements[0]
    ->count());
}