public function WorkspaceTest::testDeleteWorkspaceActiveForUser in Multiversion 8
File
- tests/src/Functional/WorkspaceTest.php, line 92
Class
- WorkspaceTest
- Test the workspace entity.
Namespace
Drupal\Tests\multiversion\Functional
Code
public function testDeleteWorkspaceActiveForUser() {
$cats = Workspace::create([
'label' => 'Cats',
'machine_name' => 'cats',
'type' => 'basic',
]);
$cats
->save();
$dogs = Workspace::create([
'label' => 'Dogs',
'machine_name' => 'dogs',
'type' => 'basic',
]);
$dogs
->save();
$dogs_id = $dogs
->id();
$alina = $this
->drupalCreateUser([
'administer workspaces',
]);
$john = $this
->drupalCreateUser([
'administer workspaces',
]);
$this
->drupalLogin($alina);
$this->workspaceManager
->setActiveWorkspace($cats);
$this
->assertEqual('cats', $this->workspaceManager
->getActiveWorkspace()
->getMachineName());
$this
->drupalLogin($john);
$this->workspaceManager
->setActiveWorkspace($dogs);
$this
->assertEqual('dogs', $this->workspaceManager
->getActiveWorkspace()
->getMachineName());
$this
->drupalLogin($alina);
$this
->assertEqual('cats', $this->workspaceManager
->getActiveWorkspace()
->getMachineName());
$dogs
->delete();
\Drupal::service('cron')
->run();
$this
->assertEmpty(Workspace::load($dogs_id));
$this
->drupalLogin($john);
$this
->assertEqual('live', $this->workspaceManager
->getActiveWorkspace()
->getMachineName());
}