You are here

public function NodeAccessTest::testGetDefaultRevisionId in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/content_moderation/tests/src/Kernel/NodeAccessTest.php \Drupal\Tests\content_moderation\Kernel\NodeAccessTest::testGetDefaultRevisionId()

@covers \Drupal\content_moderation\ModerationInformation::getDefaultRevisionId

File

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

Class

NodeAccessTest
Tests with node access enabled.

Namespace

Drupal\Tests\content_moderation\Kernel

Code

public function testGetDefaultRevisionId() {

  // 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
    ->getDefaultRevisionId('node', $node
    ->id()));

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