function NodeRevisionsTest::createRevisions

Same name in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeRevisionsTest.php \Drupal\Tests\node\Functional\NodeRevisionsTest::createRevisions()
  2. 8.9.x core/modules/node/tests/src/Functional/NodeRevisionsTest.php \Drupal\Tests\node\Functional\NodeRevisionsTest::createRevisions()
  3. 10 core/modules/node/tests/src/Functional/NodeRevisionsTest.php \Drupal\Tests\node\Functional\NodeRevisionsTest::createRevisions()

Creates a series of revisions for the specified node.

Parameters

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

int $count: The number of revisions to be created.

1 call to NodeRevisionsTest::createRevisions()
NodeRevisionsTest::testRevisionTranslationRevert in core/modules/node/tests/src/Functional/NodeRevisionsTest.php
Tests the revision translations are correctly reverted.

File

core/modules/node/tests/src/Functional/NodeRevisionsTest.php, line 473

Class

NodeRevisionsTest
Tests per-content-type node CRUD operation permissions.

Namespace

Drupal\Tests\node\Functional

Code

protected function createRevisions(NodeInterface $node, $count) : void {
    for ($i = 0; $i < $count; $i++) {
        $node->title = $this->randomString();
        $node->untranslatable_string_field->value = $this->randomString();
        $node->setNewRevision(TRUE);
        $node->save();
    }
}

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