You are here

protected function WorkspaceIntegrationTest::assertEntityRevisionLoad in Drupal 8

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

Asserts that non-default revisions are not changed.

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.

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

File

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

Class

WorkspaceIntegrationTest
Tests a complete deployment scenario across different workspaces.

Namespace

Drupal\Tests\workspaces\Kernel

Code

protected function assertEntityRevisionLoad(array $expected_values, $entity_type_id) {
  $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());
  }
}