function ModerationStateNodeTest::testNoContentModerationPermissions

Same name in other branches
  1. 9 core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php \Drupal\Tests\content_moderation\Functional\ModerationStateNodeTest::testNoContentModerationPermissions()
  2. 10 core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php \Drupal\Tests\content_moderation\Functional\ModerationStateNodeTest::testNoContentModerationPermissions()
  3. 11.x core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php \Drupal\Tests\content_moderation\Functional\ModerationStateNodeTest::testNoContentModerationPermissions()

Tests the workflow when a user has no Content Moderation permissions.

File

core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php, line 155

Class

ModerationStateNodeTest
Tests general content moderation workflow for nodes.

Namespace

Drupal\Tests\content_moderation\Functional

Code

public function testNoContentModerationPermissions() {
    $session_assert = $this->assertSession();
    // Create a user with quite advanced node permissions but no content
    // moderation permissions.
    $limited_user = $this->createUser([
        'administer nodes',
        'bypass node access',
    ]);
    $this->drupalLogin($limited_user);
    // Check the user can see the content entity form, but can't see the
    // moderation state select or save the entity form.
    $this->drupalGet('node/add/moderated_content');
    $session_assert->statusCodeEquals(200);
    $session_assert->fieldNotExists('moderation_state[0][state]');
    $this->drupalPostForm(NULL, [
        'title[0][value]' => 'moderated content',
    ], 'Save');
    $session_assert->pageTextContains('You do not have access to transition from Draft to Draft');
}

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