You are here

protected function WorkspaceTestTrait::getUnassociatedRevisions in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php \Drupal\Tests\workspaces\Kernel\WorkspaceTestTrait::getUnassociatedRevisions()

Returns all the revisions which are not associated with any workspace.

Parameters

string $entity_type_id: An entity type ID to find revisions for.

int[]|string[]|null $entity_ids: (optional) An array of entity IDs to filter the results by. Defaults to NULL.

Return value

array An array of entity IDs, keyed by revision IDs.

1 call to WorkspaceTestTrait::getUnassociatedRevisions()
WorkspaceCRUDTest::testDeletingWorkspaces in core/modules/workspaces/tests/src/Kernel/WorkspaceCRUDTest.php
Tests the deletion of workspaces.

File

core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php, line 120

Class

WorkspaceTestTrait
A trait with common workspaces testing functionality.

Namespace

Drupal\Tests\workspaces\Kernel

Code

protected function getUnassociatedRevisions($entity_type_id, $entity_ids = NULL) {
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinition($entity_type_id);
  $query = \Drupal::entityTypeManager()
    ->getStorage($entity_type_id)
    ->getQuery()
    ->allRevisions()
    ->accessCheck(FALSE)
    ->notExists($entity_type
    ->get('revision_metadata_keys')['workspace']);
  if ($entity_ids) {
    $query
      ->condition($entity_type
      ->getKey('id'), $entity_ids, 'IN');
  }
  return $query
    ->execute();
}