function WorkflowAccessControlHandlerTest::testCheckCreateAccess

Same name and namespace in other branches
  1. 9 core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php \Drupal\Tests\workflows\Kernel\WorkflowAccessControlHandlerTest::testCheckCreateAccess()
  2. 8.9.x core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php \Drupal\Tests\workflows\Kernel\WorkflowAccessControlHandlerTest::testCheckCreateAccess()
  3. 11.x core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php \Drupal\Tests\workflows\Kernel\WorkflowAccessControlHandlerTest::testCheckCreateAccess()

@covers ::checkCreateAccess

File

core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php, line 75

Class

WorkflowAccessControlHandlerTest
@coversDefaultClass \Drupal\workflows\WorkflowAccessControlHandler[[api-linebreak]] @group workflows @group #slow

Namespace

Drupal\Tests\workflows\Kernel

Code

public function testCheckCreateAccess() : void {
  // A user must have the correct permission to create a workflow.
  $this->assertEquals(AccessResult::neutral()->addCacheContexts([
    'user.permissions',
  ])
    ->setReason("The 'administer workflows' permission is required."), $this->accessControlHandler
    ->createAccess(NULL, $this->user, [], TRUE));
  $this->assertEquals(AccessResult::allowed()->addCacheContexts([
    'user.permissions',
  ]), $this->accessControlHandler
    ->createAccess(NULL, $this->adminUser, [], TRUE));
  // Remove all plugin types and ensure not even the admin user is allowed to
  // create a workflow.
  workflow_type_test_set_definitions([]);
  $this->accessControlHandler
    ->resetCache();
  $this->assertEquals(AccessResult::neutral()->addCacheContexts([
    'user.permissions',
  ]), $this->accessControlHandler
    ->createAccess(NULL, $this->adminUser, [], TRUE));
}

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