You are here

protected function ModerationStateTestBase::grantUserPermissionToCreateContentOfType in Workbench Moderation 8

Grants given user permission to create content of given type.

Parameters

\Drupal\Core\Session\AccountInterface $account: User to grant permission to.

string $content_type_id: Content type ID.

6 calls to ModerationStateTestBase::grantUserPermissionToCreateContentOfType()
ModerationFormTest::setUp in tests/src/Functional/ModerationFormTest.php
Sets the test up.
ModerationFormTest::testModerationFormSetsRevisionAuthor in tests/src/Functional/ModerationFormTest.php
Tests the revision author is updated when the moderation form is used.
ModerationStateNodeTest::setUp in tests/src/Functional/ModerationStateNodeTest.php
Sets the test up.
ModerationStateNodeTypeTest::testEnablingOnExistingContent in tests/src/Functional/ModerationStateNodeTypeTest.php
A node type without moderation state enabled.
ModerationStateNodeTypeTest::testNotModerated in tests/src/Functional/ModerationStateNodeTypeTest.php
A node type without moderation state disabled.

... See full list

File

tests/src/Functional/ModerationStateTestBase.php, line 146

Class

ModerationStateTestBase
Defines a base class for moderation state tests.

Namespace

Drupal\Tests\workbench_moderation\Functional

Code

protected function grantUserPermissionToCreateContentOfType(AccountInterface $account, $content_type_id) {
  $role_ids = $account
    ->getRoles(TRUE);

  /* @var \Drupal\user\RoleInterface $role */
  $role_id = reset($role_ids);
  $role = Role::load($role_id);
  $role
    ->grantPermission(sprintf('create %s content', $content_type_id));
  $role
    ->grantPermission(sprintf('edit any %s content', $content_type_id));
  $role
    ->grantPermission(sprintf('delete any %s content', $content_type_id));
  $role
    ->save();
}