You are here

protected function WorkspaceIntegrationTest::assertEntityRevisionLoad in Drupal 10

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

Asserts that non-default revisions are not changed.

@internal

Parameters

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

string $entity_type_id: The ID of the entity type to check.

File

core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php, line 892

Class

WorkspaceIntegrationTest
Tests a complete publishing scenario across different workspaces.

Namespace

Drupal\Tests\workspaces\Kernel

Code

protected function assertEntityRevisionLoad(array $expected_values, string $entity_type_id) : void {
  $entity_keys = $this->entityTypeManager
    ->getDefinition($entity_type_id)
    ->getKeys();
  $id_key = $entity_keys['id'];
  $revision_key = $entity_keys['revision'];
  $label_key = $entity_keys['label'];
  $published_key = $entity_keys['published'];

  /** @var \Drupal\Core\Entity\RevisionableInterface[]|\Drupal\Core\Entity\EntityPublishedInterface[] $entities */
  $entities = $this->entityTypeManager
    ->getStorage($entity_type_id)
    ->loadMultipleRevisions(array_column($expected_values, $revision_key));
  foreach ($expected_values as $expected_revision) {
    $revision_id = $expected_revision[$revision_key];
    $this
      ->assertEquals($expected_revision[$id_key], $entities[$revision_id]
      ->id());
    $this
      ->assertEquals($expected_revision[$revision_key], $entities[$revision_id]
      ->getRevisionId());
    $this
      ->assertEquals($expected_revision[$label_key], $entities[$revision_id]
      ->label());
    $this
      ->assertEquals($expected_revision[$published_key], $entities[$revision_id]
      ->isPublished());
  }
}