function LayoutBuilderTest::testNonBundleEntityType

Same name and namespace in other branches
  1. 8.9.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testNonBundleEntityType()
  2. 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testNonBundleEntityType()
  3. 11.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testNonBundleEntityType()

Tests the Layout Builder UI for an entity type without a bundle.

File

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

Class

LayoutBuilderTest
Tests the Layout Builder UI.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function testNonBundleEntityType() {
    $assert_session = $this->assertSession();
    $page = $this->getSession()
        ->getPage();
    // Log in as a user that can edit layout templates.
    $this->drupalLogin($this->drupalCreateUser([
        'configure any layout',
        'administer user display',
    ]));
    $this->drupalGet('admin/config/people/accounts/display/default');
    $this->submitForm([
        'layout[enabled]' => TRUE,
    ], 'Save');
    $this->submitForm([
        'layout[allow_custom]' => TRUE,
    ], 'Save');
    $page->clickLink('Manage layout');
    $assert_session->pageTextContains('You are editing the layout template for all users.');
    $this->drupalGet('user');
    $page->clickLink('Layout');
    $assert_session->pageTextContains('You are editing the layout for this user. Edit the template for all users instead.');
    // Log in as a user that cannot edit layout templates.
    $this->drupalLogin($this->drupalCreateUser([
        'configure any layout',
    ]));
    $this->drupalGet('user');
    $page->clickLink('Layout');
    $assert_session->pageTextContains('You are editing the layout for this user.');
    $assert_session->pageTextNotContains('Edit the template for all users instead.');
}

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