3 namespace Drupal\Tests\workspaces\Functional;
5 use Drupal\Tests\BrowserTestBase;
6 use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
9 * Tests access bypass permission controls on workspaces.
13 class WorkspaceBypassTest extends BrowserTestBase {
15 use WorkspaceTestUtilities;
16 use ContentTypeCreationTrait;
21 public static $modules = ['node', 'user', 'block', 'workspaces'];
24 * Verifies that a user can edit anything in a workspace they own.
26 public function testBypassOwnWorkspace() {
31 'bypass entity access own workspace',
34 $this->createContentType(['type' => 'test', 'label' => 'Test']);
35 $this->setupWorkspaceSwitcherBlock();
37 $ditka = $this->drupalCreateUser(array_merge($permissions, ['create test content']));
39 // Login as a limited-access user and create a workspace.
40 $this->drupalLogin($ditka);
41 $bears = $this->createWorkspaceThroughUi('Bears', 'bears');
42 $this->switchToWorkspace($bears);
44 // Now create a node in the Bears workspace, as the owner of that workspace.
45 $ditka_bears_node = $this->createNodeThroughUi('Ditka Bears node', 'test');
46 $ditka_bears_node_id = $ditka_bears_node->id();
48 // Editing both nodes should be possible.
49 $this->drupalGet('/node/' . $ditka_bears_node_id . '/edit');
50 $this->assertSession()->statusCodeEquals(200);
52 // Create a new user that should be able to edit anything in the Bears
54 $lombardi = $this->drupalCreateUser(array_merge($permissions, ['view any workspace']));
55 $this->drupalLogin($lombardi);
56 $this->switchToWorkspace($bears);
58 // Because editor 2 has the bypass permission, he should be able to create
60 $this->drupalGet('/node/' . $ditka_bears_node_id . '/edit');
61 $this->assertSession()->statusCodeEquals(403);