function FieldLayoutTest::testLayoutForms

Same name and namespace in other branches
  1. 9 core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php \Drupal\Tests\field_layout\FunctionalJavascript\FieldLayoutTest::testLayoutForms()
  2. 8.9.x core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php \Drupal\Tests\field_layout\FunctionalJavascript\FieldLayoutTest::testLayoutForms()
  3. 11.x core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php \Drupal\Tests\field_layout\FunctionalJavascript\FieldLayoutTest::testLayoutForms()

Tests layout plugins with forms.

File

core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php, line 219

Class

FieldLayoutTest
Tests using field layout for entity displays.

Namespace

Drupal\Tests\field_layout\FunctionalJavascript

Code

public function testLayoutForms() : void {
  $this->drupalGet('entity_test/structure/entity_test/display');
  // Switch to a field layout with settings.
  $this->click('#edit-field-layouts');
  // Test switching between layouts with and without forms.
  $this->getSession()
    ->getPage()
    ->selectFieldOption('field_layout', 'layout_test_plugin');
  $this->assertSession()
    ->assertExpectedAjaxRequest(1);
  $this->assertSession()
    ->fieldExists('settings_wrapper[layout_settings][setting_1]');
  $this->getSession()
    ->getPage()
    ->selectFieldOption('field_layout', 'layout_test_2col');
  $this->assertSession()
    ->assertExpectedAjaxRequest(2);
  $this->assertSession()
    ->fieldNotExists('settings_wrapper[layout_settings][setting_1]');
  $this->getSession()
    ->getPage()
    ->selectFieldOption('field_layout', 'layout_test_plugin');
  $this->assertSession()
    ->assertExpectedAjaxRequest(3);
  $this->assertSession()
    ->fieldExists('settings_wrapper[layout_settings][setting_1]');
  // Move the test field to the content region.
  $this->getSession()
    ->getPage()
    ->pressButton('Show row weights');
  $this->getSession()
    ->getPage()
    ->selectFieldOption('fields[field_test_text][region]', 'content');
  $this->submitForm([], 'Save');
  $this->drupalGet('entity_test/1');
  $this->assertSession()
    ->pageTextContains('Blah: Default');
  // Update the field layout settings.
  $this->drupalGet('entity_test/structure/entity_test/display');
  $this->click('#edit-field-layouts');
  $this->getSession()
    ->getPage()
    ->fillField('settings_wrapper[layout_settings][setting_1]', 'Test text');
  $this->submitForm([], 'Save');
  $this->drupalGet('entity_test/1');
  $this->assertSession()
    ->pageTextContains('Blah: Test text');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.