function EntityRevisionsTest::testSaveInHookEntityInsert

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionsTest::testSaveInHookEntityInsert()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionsTest::testSaveInHookEntityInsert()
  3. 11.x 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());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.