function EntityFormDisplayAccessControlHandlerTest::assertAllowOperations

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php \Drupal\Tests\Core\Entity\Access\EntityFormDisplayAccessControlHandlerTest::assertAllowOperations()
  2. 10 core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php \Drupal\Tests\Core\Entity\Access\EntityFormDisplayAccessControlHandlerTest::assertAllowOperations()
  3. 11.x core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php \Drupal\Tests\Core\Entity\Access\EntityFormDisplayAccessControlHandlerTest::assertAllowOperations()

Assert method to verify the access by operations.

@internal

Parameters

array $allow_operations: A list of allowed operations.

\Drupal\Core\Session\AccountInterface $user: The account to use for get access.

1 call to EntityFormDisplayAccessControlHandlerTest::assertAllowOperations()
EntityFormDisplayAccessControlHandlerTest::testAccess in core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
@covers ::access @covers ::checkAccess

File

core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php, line 204

Class

EntityFormDisplayAccessControlHandlerTest
@coversDefaultClass \Drupal\Core\Entity\Entity\Access\EntityFormDisplayAccessControlHandler @group Entity

Namespace

Drupal\Tests\Core\Entity\Access

Code

public function assertAllowOperations(array $allow_operations, AccountInterface $user) : void {
    foreach ([
        'view',
        'update',
        'delete',
    ] as $operation) {
        $expected = in_array($operation, $allow_operations);
        $actual = $this->accessControlHandler
            ->access($this->entity, $operation, $user);
        $this->assertSame($expected, $actual, "Access problem with '{$operation}' operation.");
    }
}

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