You are here

public function EntityRevisionsTest::testSaveInHookEntityInsert in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionsTest::testSaveInHookEntityInsert()
  2. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionsTest::testSaveInHookEntityInsert()

Tests re-saving the entity in entity_test_entity_insert().

File

core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionsTest.php, line 162

Class

EntityRevisionsTest
Tests the loaded Revision of an entity.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testSaveInHookEntityInsert() {

  // Create an entity which will be saved again in entity_test_entity_insert().
  $entity = EntityTestMulRev::create([
    'name' => 'EntityLoadedRevisionTest',
  ]);
  $entity
    ->save();
  $loadedRevisionId = \Drupal::state()
    ->get('entity_test.loadedRevisionId');
  $this
    ->assertEquals($entity
    ->getLoadedRevisionId(), $loadedRevisionId);
  $this
    ->assertEquals($entity
    ->getRevisionId(), $entity
    ->getLoadedRevisionId());
}