function FieldLayoutTest::testChangingFormatterAndRegion
Same name in other branches
- 9 core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php \Drupal\Tests\field_layout\FunctionalJavascript\FieldLayoutTest::testChangingFormatterAndRegion()
- 8.9.x core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php \Drupal\Tests\field_layout\FunctionalJavascript\FieldLayoutTest::testChangingFormatterAndRegion()
- 10 core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php \Drupal\Tests\field_layout\FunctionalJavascript\FieldLayoutTest::testChangingFormatterAndRegion()
Tests changing the formatter and region at the same time.
File
-
core/
modules/ field_layout/ tests/ src/ FunctionalJavascript/ FieldLayoutTest.php, line 258
Class
- FieldLayoutTest
- Tests using field layout for entity displays.
Namespace
Drupal\Tests\field_layout\FunctionalJavascriptCode
public function testChangingFormatterAndRegion() : void {
$assert_session = $this->assertSession();
$page = $this->getSession()
->getPage();
// Add the test field to the content region.
$this->drupalGet('entity_test/structure/entity_test/display');
$page->find('css', '#field-test-text .handle')
->dragTo($page->find('css', '.region-content-message'));
$assert_session->assertWaitOnAjaxRequest();
$page->pressButton('Save');
$assert_session->fieldValueEquals('fields[field_test_text][region]', 'content');
$assert_session->fieldValueEquals('fields[field_test_text][type]', 'text_default');
// Switch the layout to two columns.
$this->click('#edit-field-layouts');
$page->selectFieldOption('field_layout', 'layout_twocol');
$assert_session->assertWaitOnAjaxRequest();
$page->pressButton('Save');
$assert_session->fieldValueEquals('fields[field_test_text][region]', 'first');
// Change the formatter and move to another region.
$page->selectFieldOption('fields[field_test_text][type]', 'text_trimmed');
$assert_session->assertWaitOnAjaxRequest();
$page->find('css', '#field-test-text .handle')
->dragTo($page->find('css', '.region-second-message'));
$assert_session->assertWaitOnAjaxRequest();
$page->pressButton('Save');
// Assert that both the formatter and region change are persisted.
$assert_session->fieldValueEquals('fields[field_test_text][region]', 'second');
$assert_session->fieldValueEquals('fields[field_test_text][type]', 'text_trimmed');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.