You are here

public function LayoutBuilderTest::testExtraFields in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testExtraFields()
  2. 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testExtraFields()

Tests that extra fields work before and after enabling Layout Builder.

File

core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php, line 867

Class

LayoutBuilderTest
Tests the Layout Builder UI.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function testExtraFields() {
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'configure any layout',
    'administer node display',
  ]));
  $this
    ->drupalGet('node');
  $assert_session
    ->linkExists('Read more');
  $this
    ->drupalPostForm('admin/structure/types/manage/bundle_with_section_field/display/default', [
    'layout[enabled]' => TRUE,
  ], 'Save');

  // Extra fields display under "Content fields".
  $this
    ->drupalGet("admin/structure/types/manage/bundle_with_section_field/display/default/layout");
  $this
    ->clickLink('Add block');
  $page = $this
    ->getSession()
    ->getPage();
  $content_fields_category = $page
    ->find('xpath', '//details/summary[contains(text(),"Content fields")]/parent::details');
  $extra_field = strpos($content_fields_category
    ->getText(), 'Extra label');
  $this
    ->assertTrue($extra_field !== FALSE);
  $this
    ->drupalGet('node');
  $assert_session
    ->linkExists('Read more');
}