function WorkspaceAssociationTest::testMoveAllTrackedEntities
Tests moving all tracked entities of all types between workspaces.
@legacy-covers ::moveTrackedEntities
File
-
core/
modules/ workspaces/ tests/ src/ Kernel/ WorkspaceAssociationTest.php, line 350
Class
- WorkspaceAssociationTest
- Tests workspace associations.
Namespace
Drupal\Tests\workspaces\KernelCode
public function testMoveAllTrackedEntities() : void {
$entity_type_id = 'entity_test_mulrevpub';
$entity_type_id_string = 'entity_test_mulrevpub_string_id';
$workspace_association = \Drupal::service('workspaces.association');
// Create entities of different types in 'preview'.
$this->switchToWorkspace('preview');
$this->createEntity($entity_type_id, [
'name' => 'Integer entity',
]);
$this->createEntity($entity_type_id_string, [
'id' => 'str_test',
'name' => 'String entity',
]);
// Move all entities from 'preview' to 'qa'.
$workspace_association->moveTrackedEntities('preview', 'qa');
$this->assertEmpty($workspace_association->getTrackedEntities('preview', $entity_type_id)[$entity_type_id] ?? []);
$this->assertEmpty($workspace_association->getTrackedEntities('preview', $entity_type_id_string)[$entity_type_id_string] ?? []);
$this->assertCount(1, $workspace_association->getTrackedEntities('qa', $entity_type_id)[$entity_type_id]);
$this->assertCount(1, $workspace_association->getTrackedEntities('qa', $entity_type_id_string)[$entity_type_id_string]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.