You are here

protected function NodeRevisionsAllTest::createNodeRevision in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php \Drupal\Tests\node\Functional\NodeRevisionsAllTest::createNodeRevision()

Creates a new revision for a given node.

Parameters

\Drupal\node\NodeInterface $node: A node object.

Return value

\Drupal\node\NodeInterface A node object with up to date revision information.

2 calls to NodeRevisionsAllTest::createNodeRevision()
NodeRevisionsAllTest::setUp in core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
NodeRevisionsAllTest::testRevisions in core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php
Checks node revision operations.

File

core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php, line 98

Class

NodeRevisionsAllTest
Create a node with revisions and test viewing, saving, reverting, and deleting revisions for user with access to all.

Namespace

Drupal\Tests\node\Functional

Code

protected function createNodeRevision(NodeInterface $node) {

  // Create revision with a random title and body and update variables.
  $node->title = $this
    ->randomMachineName();
  $node->body = [
    'value' => $this
      ->randomMachineName(32),
    'format' => filter_default_format(),
  ];
  $node
    ->setNewRevision();

  // Ensure the revision author is a different user.
  $node
    ->setRevisionUserId($this->revisionUser
    ->id());
  $node
    ->save();
  return $node;
}