protected function WorkspaceIntegrationTest::flattenExpectedValues in Drupal 10
Same name and namespace in other branches
- 8 core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest::flattenExpectedValues()
- 9 core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest::flattenExpectedValues()
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.
File
- core/
modules/ workspaces/ tests/ src/ Kernel/ WorkspaceIntegrationTest.php, line 976
Class
- WorkspaceIntegrationTest
- Tests a complete publishing scenario across different workspaces.
Namespace
Drupal\Tests\workspaces\KernelCode
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;
}