function RevisionableContentEntityBaseTest::createRevision

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php \Drupal\KernelTests\Core\Entity\RevisionableContentEntityBaseTest::createRevision()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php \Drupal\KernelTests\Core\Entity\RevisionableContentEntityBaseTest::createRevision()
  3. 11.x core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php \Drupal\KernelTests\Core\Entity\RevisionableContentEntityBaseTest::createRevision()

Creates a new revision in the entity of this test class.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity where revision will be created.

\Drupal\user\UserInterface $user: The author of the new revision.

int $timestamp: The timestamp of the new revision.

string $log_message: The log message of the new revision.

1 call to RevisionableContentEntityBaseTest::createRevision()
RevisionableContentEntityBaseTest::testRevisionableContentEntity in core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php
Tests the correct functionality CRUD operations of entity revisions.

File

core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php, line 197

Class

RevisionableContentEntityBaseTest
Test the revision system.

Namespace

Drupal\KernelTests\Core\Entity

Code

protected function createRevision(EntityInterface $entity, UserInterface $user, $timestamp, $log_message) {
    $entity->setNewRevision(TRUE);
    $entity->setRevisionCreationTime($timestamp);
    $entity->setRevisionUserId($user->id());
    $entity->setRevisionLogMessage($log_message);
    $entity->save();
}

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