protected function ModerationStateTestBase::grantUserPermissionToCreateContentOfType in Workbench Moderation 8.2
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.
5 calls to ModerationStateTestBase::grantUserPermissionToCreateContentOfType()
- ModerationFormTest::setUp in src/
Tests/ ModerationFormTest.php - Sets the test up.
- ModerationStateNodeTest::setUp in src/
Tests/ ModerationStateNodeTest.php - Sets the test up.
- ModerationStateNodeTypeTest::testEnablingOnExistingContent in src/
Tests/ ModerationStateNodeTypeTest.php - A node type without moderation state enabled.
- ModerationStateNodeTypeTest::testNotModerated in src/
Tests/ ModerationStateNodeTypeTest.php - A node type without moderation state disabled.
- NodeAccessTest::setUp in src/
Tests/ NodeAccessTest.php - Sets the test up.
File
- src/
Tests/ ModerationStateTestBase.php, line 138
Class
- ModerationStateTestBase
- Defines a base class for moderation state tests.
Namespace
Drupal\workbench_moderation\TestsCode
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();
}