WorkspaceBypassTest.php in Workspace 8.2
File
tests/src/Functional/WorkspaceBypassTest.php
View source
<?php
namespace Drupal\Tests\workspace\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
class WorkspaceBypassTest extends BrowserTestBase {
use WorkspaceTestUtilities;
use ContentTypeCreationTrait;
public static $modules = [
'node',
'user',
'block',
'workspace',
];
public function testBypassOwnWorkspace() {
$permissions = [
'create workspace',
'edit own workspace',
'view own workspace',
'bypass entity access own workspace',
];
$this
->createContentType([
'type' => 'test',
'label' => 'Test',
]);
$this
->setupWorkspaceSwitcherBlock();
$ditka = $this
->drupalCreateUser(array_merge($permissions, [
'create test content',
]));
$this
->drupalLogin($ditka);
$bears = $this
->createWorkspaceThroughUi('Bears', 'bears');
$this
->switchToWorkspace($bears);
$ditka_bears_node = $this
->createNodeThroughUi('Ditka Bears node', 'test');
$ditka_bears_node_id = $ditka_bears_node
->id();
$this
->drupalGet('/node/' . $ditka_bears_node_id . '/edit');
$this
->assertSession()
->statusCodeEquals(200);
$lombardi = $this
->drupalCreateUser(array_merge($permissions, [
'view any workspace',
]));
$this
->drupalLogin($lombardi);
$this
->switchToWorkspace($bears);
$this
->drupalGet('/node/' . $ditka_bears_node_id . '/edit');
$this
->assertSession()
->statusCodeEquals(403);
}
}