You are here

public function NodeRevisionsAutocleanTest::createNodeWithRevisions in Node Revisions Autoclean 8

Creates node and its revisions.

Parameters

string $title: Node's title.

string $type: Node's type.

Return value

Drupal\node\Entity\Node The created node.

4 calls to NodeRevisionsAutocleanTest::createNodeWithRevisions()
NodeRevisionsAutocleanTest::testDeleteDateRevisions in tests/src/Functional/NodeRevisionsAutocleanTest.php
Tests that revisions are deleted as they should be with date constraint.
NodeRevisionsAutocleanTest::testDeleteMultilanguageRevisions in tests/src/Functional/NodeRevisionsAutocleanTest.php
Tests node revisions autoclean with multiple languages.
NodeRevisionsAutocleanTest::testDeleteRevisions in tests/src/Functional/NodeRevisionsAutocleanTest.php
Tests that revisions are deleted as they should be.
NodeRevisionsAutocleanTest::testInitialRevisions in tests/src/Functional/NodeRevisionsAutocleanTest.php
Test revisions.

File

tests/src/Functional/NodeRevisionsAutocleanTest.php, line 100

Class

NodeRevisionsAutocleanTest
Class NodeRevisionsAutocleanTest.

Namespace

Drupal\Tests\node_revisions_autoclean\Functional

Code

public function createNodeWithRevisions($title, $type = 'page') {
  $user = $this
    ->drupalCreateUser();
  $node = Node::create([
    'type' => $type,
    'title' => '1',
  ]);
  $node
    ->setPublished(TRUE);
  $node
    ->save();
  $this
    ->addRevision($node, $user, FALSE);
  $this
    ->addRevision($node, $user, TRUE);
  $this
    ->addRevision($node, $user, FALSE);
  $this
    ->addRevision($node, $user, TRUE);
  $this
    ->addRevision($node, $user, FALSE);
  $this
    ->addRevision($node, $user, TRUE);
  $this
    ->addRevision($node, $user, TRUE);
  $this
    ->addRevision($node, $user, FALSE);
  $this
    ->addRevision($node, $user, FALSE);
  $this
    ->addRevision($node, $user, FALSE);
  $this
    ->addRevision($node, $user, FALSE);
  return $node;
}