WorkspaceViewTest.php in Workspace 8.2
File
tests/src/Functional/WorkspaceViewTest.php
View source
<?php
namespace Drupal\Tests\workspace\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\workspace\Entity\Workspace;
class WorkspaceViewTest extends BrowserTestBase {
use WorkspaceTestUtilities;
public static $modules = [
'workspace',
'workspace',
];
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/workspace/manage/{$bears->id()}/activate");
$this
->assertSession()
->statusCodeEquals(403);
$this
->drupalGet("admin/config/workflow/workspace/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/workspace/manage/{$bears->id()}/activate");
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalGet("admin/config/workflow/workspace/manage/{$packers->id()}/activate");
$this
->assertSession()
->statusCodeEquals(200);
}
}