You are here

private function PanelsInPlaceEditorTest::changeLayout in Lightning Layout 8

Changes the layout of the current entity in the Panels IPE.

Parameters

string $category: The layout category, e.g. "Columns: 3".

string $layout_id: The layout's plugin ID.

1 call to PanelsInPlaceEditorTest::changeLayout()
PanelsInPlaceEditorTest::testChangeLayouts in tests/src/FunctionalJavascript/PanelsInPlaceEditorTest.php
Tests changing layouts in the in-place editor.

File

tests/src/FunctionalJavascript/PanelsInPlaceEditorTest.php, line 85

Class

PanelsInPlaceEditorTest
Tests Lightning Layout's integration with the Panels in-place editor.

Namespace

Drupal\Tests\lightning_layout\FunctionalJavascript

Code

private function changeLayout($category, $layout_id) {
  $page = $this
    ->getSession()
    ->getPage();
  $assert_session = $this
    ->assertSession();
  $page
    ->clickLink('Change Layout');
  $this
    ->waitForVisibleElement('css', "a[data-category='{$category}']")
    ->click();
  $this
    ->waitForVisibleElement('css', "a[data-layout-id='{$layout_id}']")
    ->click();
  $assert_session
    ->assertWaitOnAjaxRequest();

  // If the layout is configurable (as it may be in Drupal 8.8 and later), we
  // need to click another button.
  $layout_class = $this->container
    ->get('plugin.manager.core.layout')
    ->getDefinition($layout_id)
    ->getClass();
  if (is_a($layout_class, '\\Drupal\\Core\\Plugin\\PluginFormInterface', TRUE)) {
    $page
      ->pressButton('Change Layout');
    $assert_session
      ->assertWaitOnAjaxRequest();
  }
}