public function WorkspaceTest::testWorkspaceOwner in Drupal 9
Same name and namespace in other branches
- 8 core/modules/workspaces/tests/src/Functional/WorkspaceTest.php \Drupal\Tests\workspaces\Functional\WorkspaceTest::testWorkspaceOwner()
- 10 core/modules/workspaces/tests/src/Functional/WorkspaceTest.php \Drupal\Tests\workspaces\Functional\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());
}