function WorkspaceTestTrait::assertWorkspaceAssociation

Same name in other branches
  1. 9 core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php \Drupal\Tests\workspaces\Kernel\WorkspaceTestTrait::assertWorkspaceAssociation()
  2. 8.9.x core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php \Drupal\Tests\workspaces\Kernel\WorkspaceTestTrait::assertWorkspaceAssociation()
  3. 11.x 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.

7 calls to WorkspaceTestTrait::assertWorkspaceAssociation()
WorkspaceInformationTest::testCustomSupportEntityTypes in core/modules/workspaces/tests/src/Kernel/WorkspaceInformationTest.php
Tests an entity type with a custom workspace handler.
WorkspaceInformationTest::testIgnoredEntityTypes in core/modules/workspaces/tests/src/Kernel/WorkspaceInformationTest.php
Tests ignored entity types.
WorkspaceInformationTest::testSupportedEntityTypes in core/modules/workspaces/tests/src/Kernel/WorkspaceInformationTest.php
Tests fully supported entity types.
WorkspaceIntegrationTest::testWorkspaceAssociationDataIntegrity in core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
Tests the workspace association data integrity for entity CRUD operations.
WorkspaceIntegrationTest::testWorkspaceHierarchy in core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php
Tests entity tracking in workspace descendants.

... See full list

File

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

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));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.