function WorkspacesLayoutBuilderIntegrationTest::testWorkspacesLayoutTempstore

Tests workspace specific layout tempstore data.

@covers \Drupal\workspaces\WorkspacesLayoutTempstoreRepository::getKey

File

core/modules/workspaces/tests/src/FunctionalJavascript/WorkspacesLayoutBuilderIntegrationTest.php, line 195

Class

WorkspacesLayoutBuilderIntegrationTest
Tests for layout editing in workspaces.

Namespace

Drupal\Tests\workspaces\FunctionalJavascript

Code

public function testWorkspacesLayoutTempstore() : void {
    $assert_session = $this->assertSession();
    $this->drupalGet('node/1');
    $assert_session->pageTextContains('The DEFAULT block body');
    $second_user = $this->drupalCreateUser([
        'access contextual links',
        'configure any layout',
        'administer node display',
        'administer node fields',
        'create and edit custom blocks',
        'administer blocks',
        'administer content types',
        'administer workspaces',
        'view any workspace',
        'administer site configuration',
        'administer nodes',
        'bypass node access',
    ]);
    $stage = Workspace::load('stage');
    $this->switchToWorkspace($stage);
    // Confirm the block can be edited.
    $this->drupalGet('node/1/layout');
    $workspace_block_body = 'The WS block body';
    $this->configureInlineBlock('The DEFAULT block body', $workspace_block_body);
    // Switch to another user and check the layout edit page in the live
    // workspace and verify that the changes are not visible there. Switching
    // the user automatically switches the workspace to Live.
    $this->drupalLogin($second_user);
    $this->drupalGet('node/1/layout');
    $assert_session->pageTextNotContains($workspace_block_body);
    $assert_session->pageTextContains('The DEFAULT block body');
    $live_block_body = 'Live edit block body';
    $this->configureInlineBlock('The DEFAULT block body', $live_block_body);
    $assert_session->pageTextContains($live_block_body);
    $assert_session->pageTextNotContains('The DEFAULT block body');
    $this->drupalGet('node/1');
    $assert_session->pageTextNotContains($live_block_body);
    $assert_session->pageTextContains('The DEFAULT block body');
    $this->drupalLogin($this->defaultUser);
    $this->switchToWorkspace($stage);
    $this->drupalGet('node/1/layout');
    $assert_session->pageTextContains($workspace_block_body);
    $assert_session->pageTextNotContains($live_block_body);
    $assert_session->pageTextNotContains('The DEFAULT block body');
    $this->drupalGet('node/1');
    $assert_session->pageTextNotContains($workspace_block_body);
    $assert_session->pageTextContains('The DEFAULT block body');
}

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