function WorkspaceTest::testWorkspaceOwner
Tests changing the owner of a workspace.
File
- 
              core/modules/ workspaces/ tests/ src/ Functional/ WorkspaceTest.php, line 127 
Class
- WorkspaceTest
- Test the workspace entity.
Namespace
Drupal\Tests\workspaces\FunctionalCode
public function testWorkspaceOwner() {
  $this->drupalLogin($this->editor1);
  $this->drupalGet('/admin/config/workflow/workspaces/add');
  $this->submitForm([
    '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->drupalGet('/admin/config/workflow/workspaces/manage/test_workspace/edit');
  $this->submitForm([
    '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.
