You are here

protected function WorkspaceTestTrait::assertWorkspaceAssociation 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::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.

3 calls to WorkspaceTestTrait::assertWorkspaceAssociation()
WorkspaceIntegrationTest::testWorkspaceHierarchy in core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
Tests entity tracking in workspace descendants.
WorkspaceIntegrationTest::testWorkspaces in core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
Tests various scenarios for creating and publishing content in workspaces.
WorkspaceMergerTest::testWorkspaceMerger in core/modules/workspaces/tests/src/Kernel/WorkspaceMergerTest.php
Tests workspace merging.

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 = isset($tracked_entities[$entity_type_id]) ? $tracked_entities[$entity_type_id] : [];
    $this
      ->assertEquals($expected_tracked_revision_ids, array_keys($tracked_revision_ids));
  }
}