You are here

public function NodeAccessTest::testGetLatestRevisionId in Drupal 8

@covers \Drupal\content_moderation\ModerationInformation::getLatestRevisionId @group legacy @expectedDeprecation Drupal\content_moderation\ModerationInformation::getLatestRevisionId is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId() instead. See https://www.drupal.org/node/3087295

File

core/modules/content_moderation/tests/src/Kernel/NodeAccessTest.php, line 92

Class

NodeAccessTest
Tests with node access enabled.

Namespace

Drupal\Tests\content_moderation\Kernel

Code

public function testGetLatestRevisionId() {

  // Create an admin user.
  $user = $this
    ->createUser([], NULL, TRUE);
  \Drupal::currentUser()
    ->setAccount($user);

  // Create a node.
  $node = $this
    ->createNode([
    'type' => 'page',
  ]);
  $this
    ->assertEquals($node
    ->getRevisionId(), $this->moderationInformation
    ->getLatestRevisionId('node', $node
    ->id()));

  // Create a non-admin user.
  $user = $this
    ->createUser();
  \Drupal::currentUser()
    ->setAccount($user);
  $this
    ->assertEquals($node
    ->getRevisionId(), $this->moderationInformation
    ->getLatestRevisionId('node', $node
    ->id()));
}