public function WorkspaceDeletionTest::testDeletingWorkspace in Workspace 8
File
- tests/
src/ Kernel/ WorkspaceDeletionTest.php, line 66
Class
- WorkspaceDeletionTest
- Tests for deleting workspaces.
Namespace
Drupal\Tests\workspace\KernelCode
public function testDeletingWorkspace() {
$workspace_type = WorkspaceType::create([
'id' => 'test',
'label' => 'Workspace bundle',
]);
$workspace_type
->save();
$workspace = Workspace::create([
'type' => 'test',
'machine_name' => 'le_workspace',
'label' => 'Le Workspace',
]);
$workspace
->save();
$node_type = NodeType::create([
'name' => 'le content type',
'type' => 'le_content_type',
]);
$node_type
->save();
$node = Node::create([
'type' => 'le_content_type',
'workspace' => [
'target_id' => $workspace
->id(),
],
'title' => 'le content',
]);
$node
->save();
$node2 = Node::create([
'type' => 'le_content_type',
'workspace' => [
'target_id' => $workspace
->id(),
],
'title' => 'le content deux',
]);
$node2
->save();
$node3 = Node::create([
'type' => 'le_content_type',
'workspace' => [
'target_id' => $workspace
->id(),
],
'title' => 'le content trois',
]);
$node3
->save();
$node3
->delete();
$workspace
->delete();
$this->cron
->run();
$workspaces = $this->entityTypeManager
->getStorage('workspace')
->getQuery()
->execute();
$nodes = \Drupal::entityTypeManager()
->getStorage('node')
->getOriginalStorage()
->getQuery()
->execute();
$this
->assertEmpty($workspaces, 'No workspaces');
$this
->assertEmpty($nodes, 'No nodes');
}