function LayoutBuilderQuickEditTest::testEnableDisableLayoutBuilder

Same name in other branches
  1. 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderQuickEditTest::testEnableDisableLayoutBuilder()

Tests Quick Edit boots correctly with Layout Builder defaults & overrides.

@dataProvider providerEnableDisableLayoutBuilder

Parameters

bool $use_revisions: If revisions are used.

bool $admin_permission: Whether to grant admin permissions to the user created for the test.

File

core/modules/quickedit/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php, line 138

Class

LayoutBuilderQuickEditTest
Tests that Layout Builder functions with Quick Edit.

Namespace

Drupal\Tests\quickedit\FunctionalJavascript

Code

public function testEnableDisableLayoutBuilder($use_revisions, $admin_permission = FALSE) {
    if (!$use_revisions) {
        $content_type = NodeType::load('article');
        $content_type->setNewRevision(FALSE);
        $content_type->save();
    }
    $fields = [
        'title',
        'body',
    ];
    if ($admin_permission) {
        $fields = array_merge($fields, [
            'uid',
            'created',
        ]);
        $this->drupalLogin($this->drupalCreateUser([
            'access contextual links',
            'access in-place editing',
            'access content',
            'edit any article content',
            'administer nodes',
        ]));
    }
    // Test article with Layout Builder disabled.
    $this->assertQuickEditInit($fields);
    // Test article with Layout Builder enabled.
    $this->enableLayouts('admin/structure/types/manage/article/display/default');
    $this->usingLayoutBuilder = TRUE;
    $this->assertQuickEditInit($fields);
    // Test article with Layout Builder override.
    $this->createLayoutOverride();
    $this->assertQuickEditInit($fields);
    // If we're using revisions, it's not possible to disable Layout Builder
    // without deleting the node (unless the revisions containing the override
    // would be deleted).
    if (!$use_revisions) {
        // Test article with Layout Builder when reverted back to defaults.
        $this->revertLayoutToDefaults();
        $this->assertQuickEditInit($fields);
        // Test with Layout Builder disabled after being enabled.
        $this->usingLayoutBuilder = FALSE;
        $this->disableLayoutBuilder('admin/structure/types/manage/article/display/default');
        $this->assertQuickEditInit($fields);
    }
}

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