WorkspaceViewTest.php in Drupal 9
File
core/modules/workspaces/tests/src/Functional/WorkspaceViewTest.php
View source
<?php
namespace Drupal\Tests\workspaces\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\workspaces\Entity\Workspace;
class WorkspaceViewTest extends BrowserTestBase {
use WorkspaceTestUtilities;
protected static $modules = [
'workspaces',
];
protected $defaultTheme = 'stark';
public function testViewOwnWorkspace() {
$permissions = [
'access administration pages',
'administer site configuration',
'create workspace',
'edit own workspace',
'view own workspace',
];
$editor1 = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($editor1);
$this
->createWorkspaceThroughUi('Bears', 'bears');
$bears = Workspace::load('bears');
$editor2 = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($editor2);
$this
->createWorkspaceThroughUi('Packers', 'packers');
$packers = Workspace::load('packers');
$this
->drupalGet("admin/config/workflow/workspaces/manage/{$bears->id()}/activate");
$this
->assertSession()
->statusCodeEquals(403);
$this
->drupalGet("admin/config/workflow/workspaces/manage/{$packers->id()}/activate");
$this
->assertSession()
->statusCodeEquals(200);
}
public function testViewAnyWorkspace() {
$permissions = [
'access administration pages',
'administer site configuration',
'create workspace',
'edit own workspace',
'view any workspace',
];
$editor1 = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($editor1);
$this
->createWorkspaceThroughUi('Bears', 'bears');
$bears = Workspace::load('bears');
$editor2 = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($editor2);
$this
->createWorkspaceThroughUi('Packers', 'packers');
$packers = Workspace::load('packers');
$this
->drupalGet("admin/config/workflow/workspaces/manage/{$bears->id()}/activate");
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalGet("admin/config/workflow/workspaces/manage/{$packers->id()}/activate");
$this
->assertSession()
->statusCodeEquals(200);
}
}