WorkspaceTest.php in Multiversion 8
File
tests/src/Functional/Views/WorkspaceTest.php
View source
<?php
namespace Drupal\Tests\multiversion\Functional\Views;
use Drupal\multiversion\Entity\Workspace;
class WorkspaceTest extends MultiversionTestBase {
protected $strictConfigSchema = FALSE;
public static $testViews = [
'test_current_workspace',
];
public function testWorkspace() {
$admin_user = $this
->drupalCreateUser([
'administer workspaces',
'bypass node access',
]);
$uid = $admin_user
->id();
$this
->drupalLogin($admin_user);
$workspace_manager = \Drupal::service('workspace.manager');
$initial_workspace = $workspace_manager
->getActiveWorkspace();
$node1 = $this
->drupalCreateNode([
'uid' => $uid,
]);
$node2 = $this
->drupalCreateNode([
'uid' => $uid,
]);
$new_workspace = Workspace::create([
'machine_name' => 'new_workspace',
'label' => 'New Workspace',
'type' => 'basic',
]);
$new_workspace
->save();
$workspace_manager
->setActiveWorkspace($new_workspace);
$this
->assertEqual($new_workspace
->id(), $workspace_manager
->getActiveWorkspaceId());
$node3 = $this
->drupalCreateNode([
'uid' => $uid,
]);
$node4 = $this
->drupalCreateNode([
'uid' => $uid,
]);
$this
->drupalGet('test_current_workspace');
$this
->assertNoText($node1
->label());
$this
->assertNoText($node2
->label());
$this
->assertText($node3
->label());
$this
->assertText($node4
->label());
$workspace_manager
->setActiveWorkspace($initial_workspace);
$this
->assertEqual($initial_workspace
->id(), $workspace_manager
->getActiveWorkspaceId());
$this
->drupalGet('test_current_workspace');
$this
->assertText($node1
->label());
$this
->assertText($node2
->label());
$this
->assertNoText($node3
->label());
$this
->assertNoText($node4
->label());
}
}
Classes
Name |
Description |
WorkspaceTest |
Tests the workspace and current_workspace field handlers. |