You are here

public function PanelizerTest::testCreateLayout in Lightning Layout 8

Tests creating a Panelizer layout in the wizard.

File

tests/src/Functional/PanelizerTest.php, line 52

Class

PanelizerTest
Tests basic integration with Panelizer.

Namespace

Drupal\Tests\lightning_layout\Functional

Code

public function testCreateLayout() {
  $assert_session = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $account = $this
    ->drupalCreateUser([
    'administer panelizer',
    'administer panelizer node landing_page defaults',
    'administer node display',
  ]);
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet("/admin/structure/panelizer/add/node/landing_page/full");
  $page
    ->pressButton('Next');
  $page
    ->fillField('Wizard name', 'Foo');
  $page
    ->fillField('Machine-readable name', 'foo');
  $page
    ->pressButton('Next');
  $page
    ->pressButton('Next');
  $page
    ->pressButton('Next');

  // If the layout has a configuration form, skip that.
  $form_id = $assert_session
    ->hiddenFieldExists('form_id')
    ->getValue();
  if ($form_id === 'panels_layout_settings_form') {
    $page
      ->pressButton('Next');
  }
  $page
    ->fillField('Page title', '[node:title]');
  $page
    ->clickLink('Add new block');
  $page
    ->clickLink('Authored by');
  $page
    ->selectFieldOption('region', 'content');
  $page
    ->pressButton('Add block');
  $block = $this
    ->getBlockRow('Authored by', 'content');
  $this
    ->assertNotEmpty($block);
  $page
    ->pressButton('Finish');
  $page
    ->pressButton('Cancel');
  $assert_session
    ->addressEquals("/admin/structure/types/manage/landing_page/display/full");
  $assert_session
    ->pageTextContains('Foo');
}