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. 10 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 <a href="/api/drupal/core%21modules%21workflows%21src%21WorkflowAccessControlHandler.php/class/WorkflowAccessControlHandler/11.x" title="Access controller for the Workflow entity." class="local">\Drupal\workflows\WorkflowAccessControlHandler</a> @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.