You are here

public function NodeRevisionsAutocleanTest::testDeleteMultilanguageRevisions in Node Revisions Autoclean 8

Tests node revisions autoclean with multiple languages.

File

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

Class

NodeRevisionsAutocleanTest
Class NodeRevisionsAutocleanTest.

Namespace

Drupal\Tests\node_revisions_autoclean\Functional

Code

public function testDeleteMultilanguageRevisions() {
  $this
    ->initializeSettings(TRUE);
  $node = $this
    ->createNodeWithRevisions('1', 'page');
  $revisionsManager = \Drupal::service('node_revisions_autoclean.revisions_manager');
  $revisions = $revisionsManager
    ->loadRevisions($node);

  // There should be 3 revisions.
  $this
    ->assertEquals(7, count($revisions), 'Revisions after save : ' . count($revisions));
  $user = $this
    ->drupalCreateUser();
  $this
    ->addRevision($node, $user, TRUE);
  $this
    ->addRevision($node, $user, TRUE);
  $this
    ->addRevision($node, $user, TRUE);
  $this
    ->addRevision($node, $user, TRUE, 'fr');
  $this
    ->addRevision($node, $user, TRUE, 'fr');
  $this
    ->addRevision($node, $user, TRUE, 'fr');
  $revisions = $revisionsManager
    ->loadRevisions($node);
  $this
    ->assertEquals(6, count($revisions), 'Revisions after save : ' . count($revisions));
  $this
    ->addRevision($node, $user, FALSE, 'fr');
  $this
    ->addRevision($node, $user, FALSE, 'fr');
  $this
    ->addRevision($node, $user, FALSE, 'fr');
  $this
    ->addRevision($node, $user, FALSE, 'fr');
  $revisions = $revisionsManager
    ->loadRevisions($node);
  $this
    ->assertEquals(10, count($revisions), 'Revisions after save : ' . count($revisions));
  $this
    ->addRevision($node, $user, TRUE, 'fr');
  $revisions = $revisionsManager
    ->loadRevisions($node);
  $this
    ->assertEquals(6, count($revisions), 'Revisions after save : ' . count($revisions));
}