public function WorkspaceTest::testActiveWorkspace in Multiversion 8
File
- tests/src/Functional/WorkspaceTest.php, line 52
Class
- WorkspaceTest
- Test the workspace entity.
Namespace
Drupal\Tests\multiversion\Functional
Code
public function testActiveWorkspace() {
$live = $this->workspaceManager
->getActiveWorkspace();
$this
->assertEqual('live', $live
->getMachineName());
$test1 = Workspace::create([
'machine_name' => 'test1',
'label' => 'test1',
'type' => 'basic',
]);
$test1
->save();
$test2 = Workspace::create([
'machine_name' => 'test2',
'label' => 'test2',
'type' => 'basic',
]);
$test2
->save();
$user1 = $this
->drupalCreateUser([
'administer workspaces',
]);
$user2 = $this
->drupalCreateUser([
'administer workspaces',
]);
$this
->drupalLogin($user1);
$this
->assertEqual('live', $this->workspaceManager
->getActiveWorkspace()
->getMachineName());
$this->workspaceManager
->setActiveWorkspace($test1);
$this
->assertEqual('test1', $this->workspaceManager
->getActiveWorkspace()
->getMachineName());
$this
->drupalLogout();
$this
->assertEqual('live', $this->workspaceManager
->getActiveWorkspace()
->getMachineName());
$this
->drupalLogin($user1);
$this
->assertEqual('test1', $this->workspaceManager
->getActiveWorkspace()
->getMachineName());
$this
->drupalLogout();
$this
->drupalLogin($user2);
$this->workspaceManager
->setActiveWorkspace($test2);
$this
->assertEqual('test2', $this->workspaceManager
->getActiveWorkspace()
->getMachineName());
$this
->drupalLogout();
$this
->drupalLogin($user1);
$this
->assertEqual('test1', $this->workspaceManager
->getActiveWorkspace()
->getMachineName());
}