function NodeRevisionsAllTest::createNodeRevision
Same name in other branches
- 8.9.x core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php \Drupal\Tests\node\Functional\NodeRevisionsAllTest::createNodeRevision()
- 10 core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php \Drupal\Tests\node\Functional\NodeRevisionsAllTest::createNodeRevision()
- 11.x 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 97
Class
- NodeRevisionsAllTest
- Tests global node CRUD operation permissions.
Namespace
Drupal\Tests\node\FunctionalCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.