You are here

protected function WorkspaceIntegrationTest::flattenExpectedValues in Workspace 8.2

Flattens the expectations array defined by testWorkspaces().

Parameters

array $expected: An array as defined by testWorkspaces().

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

Return value

array An array where all the entity IDs and revision IDs are merged inside each expected values array.

1 call to WorkspaceIntegrationTest::flattenExpectedValues()
WorkspaceIntegrationTest::assertWorkspaceStatus in tests/src/Kernel/WorkspaceIntegrationTest.php
Checks entity load, entity queries and views results for a test scenario.

File

tests/src/Kernel/WorkspaceIntegrationTest.php, line 662

Class

WorkspaceIntegrationTest
Tests a complete deployment scenario across different workspaces.

Namespace

Drupal\Tests\workspace\Kernel

Code

protected function flattenExpectedValues(array $expected, $entity_type_id) {
  $flattened = [];
  $entity_keys = $this->entityTypeManager
    ->getDefinition($entity_type_id)
    ->getKeys();
  foreach ($expected as $workspace_id => $workspace_values) {
    foreach ($workspace_values as $entity_id => $entity_revisions) {
      foreach ($entity_revisions as $revision_id => $revision_values) {
        $flattened[$workspace_id][] = [
          $entity_keys['id'] => $entity_id,
          $entity_keys['revision'] => $revision_id,
        ] + $revision_values;
      }
    }
  }
  return $flattened;
}