You are here

protected function WorkspaceTestTrait::assertWorkspaceAssociation in Drupal 10

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

Checks the workspace_association records for a test scenario.

Parameters

array $expected: An array of expected values, as defined in ::testWorkspaces().

string $entity_type_id: The ID of the entity type that is being tested.

File

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

Class

WorkspaceTestTrait
A trait with common workspaces testing functionality.

Namespace

Drupal\Tests\workspaces\Kernel

Code

protected function assertWorkspaceAssociation(array $expected, $entity_type_id) {

  /** @var \Drupal\workspaces\WorkspaceAssociationInterface $workspace_association */
  $workspace_association = \Drupal::service('workspaces.association');
  foreach ($expected as $workspace_id => $expected_tracked_revision_ids) {
    $tracked_entities = $workspace_association
      ->getTrackedEntities($workspace_id, $entity_type_id);
    $tracked_revision_ids = $tracked_entities[$entity_type_id] ?? [];
    $this
      ->assertEquals($expected_tracked_revision_ids, array_keys($tracked_revision_ids));
  }
}