function WorkspaceTest::testWorkspaceOwner

Same name in other branches
  1. 9 core/modules/workspaces/tests/src/Functional/WorkspaceTest.php \Drupal\Tests\workspaces\Functional\WorkspaceTest::testWorkspaceOwner()
  2. 10 core/modules/workspaces/tests/src/Functional/WorkspaceTest.php \Drupal\Tests\workspaces\Functional\WorkspaceTest::testWorkspaceOwner()
  3. 11.x core/modules/workspaces/tests/src/Functional/WorkspaceTest.php \Drupal\Tests\workspaces\Functional\WorkspaceTest::testWorkspaceOwner()

Test changing the owner of a workspace.

File

core/modules/workspaces/tests/src/Functional/WorkspaceTest.php, line 112

Class

WorkspaceTest
Test the workspace entity.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testWorkspaceOwner() {
    $this->drupalLogin($this->editor1);
    $this->drupalPostForm('/admin/config/workflow/workspaces/add', [
        'id' => 'test_workspace',
        'label' => 'Test workspace',
    ], 'Save');
    $storage = \Drupal::entityTypeManager()->getStorage('workspace');
    $test_workspace = $storage->load('test_workspace');
    $this->assertEquals($this->editor1
        ->id(), $test_workspace->getOwnerId());
    $this->drupalPostForm('/admin/config/workflow/workspaces/manage/test_workspace/edit', [
        'uid[0][target_id]' => $this->editor2
            ->getAccountName(),
    ], 'Save');
    $test_workspace = $storage->loadUnchanged('test_workspace');
    $this->assertEquals($this->editor2
        ->id(), $test_workspace->getOwnerId());
}

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