You are here

public function JavascriptTest::testSettings in Display Suite 8.4

Same name and namespace in other branches
  1. 8.2 tests/src/FunctionalJavascript/JavascriptTest.php \Drupal\Tests\ds\FunctionalJavascript\JavascriptTest::testSettings()
  2. 8.3 tests/src/FunctionalJavascript/JavascriptTest.php \Drupal\Tests\ds\FunctionalJavascript\JavascriptTest::testSettings()

Test DS settings.

Throws

\Behat\Mink\Exception\ElementNotFoundException

\Behat\Mink\Exception\ExpectationException

\Behat\Mink\Exception\ResponseTextException

File

tests/src/FunctionalJavascript/JavascriptTest.php, line 67

Class

JavascriptTest
Tests javascript behavior for the admin UI.

Namespace

Drupal\Tests\ds\FunctionalJavascript

Code

public function testSettings() {

  // Go to the article manage display page.
  $this
    ->drupalGet('admin/structure/types/manage/article/display');
  $page = $this
    ->getSession()
    ->getPage();

  // Change the layout to 2 column layout and wait for it to be changed, see
  // if the new template is displayed.
  $page
    ->selectFieldOption('ds_layout', 'ds_2col');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertSession()
    ->pageTextContains('ds-2col--node.html.twig');
  $page
    ->pressButton('Save');
  $this
    ->drupalGet('admin/structure/types/manage/article/display');
  $this
    ->assertSession()
    ->fieldValueEquals('fields[body][region]', 'left');

  // Check that all settings are saved.

  /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */
  $display = EntityViewDisplay::load('node.article.default');
  $settings = $display
    ->getThirdPartySetting('ds', 'layout');
  $this
    ->assertSame($settings['id'], 'ds_2col');

  // Switch back to not using a layout.
  $page
    ->selectFieldOption('ds_layout', '');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $page
    ->pressButton('Save');
  $this
    ->drupalGet('admin/structure/types/manage/article/display');
  $this
    ->assertSession()
    ->fieldValueEquals('fields[body][region]', 'content');
  $display = EntityViewDisplay::load('node.article.default');
  $this
    ->assertSame('content', $display
    ->getComponent('body')['region']);
}