protected static function ResourceTestBase::entityAccess in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::entityAccess()
Checks access for the given operation on the given entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for which to check field access.
string $operation: The operation for which to check access.
\Drupal\Core\Session\AccountInterface $account: The account for which to check access.
Return value
\Drupal\Core\Access\AccessResultInterface The AccessResult.
6 calls to ResourceTestBase::entityAccess()
- CommentTest::entityAccess in tests/
src/ Functional/ CommentTest.php - Checks access for the given operation on the given entity.
- EditorTest::entityAccess in tests/
src/ Functional/ EditorTest.php - Checks access for the given operation on the given entity.
- FieldConfigTest::entityAccess in tests/
src/ Functional/ FieldConfigTest.php - Checks access for the given operation on the given entity.
- ResourceTestBase::doTestSparseFieldSets in tests/
src/ Functional/ ResourceTestBase.php - Tests sparse field sets.
- ResourceTestBase::entityFieldAccess in tests/
src/ Functional/ ResourceTestBase.php - Checks access for the given field operation on the given entity.
3 methods override ResourceTestBase::entityAccess()
- CommentTest::entityAccess in tests/
src/ Functional/ CommentTest.php - Checks access for the given operation on the given entity.
- EditorTest::entityAccess in tests/
src/ Functional/ EditorTest.php - Checks access for the given operation on the given entity.
- FieldConfigTest::entityAccess in tests/
src/ Functional/ FieldConfigTest.php - Checks access for the given operation on the given entity.
File
- tests/
src/ Functional/ ResourceTestBase.php, line 2769
Class
- ResourceTestBase
- Subclass this for every JSON API resource type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected static function entityAccess(EntityInterface $entity, $operation, AccountInterface $account) {
// The default entity access control handler assumes that permissions do not
// change during the lifetime of a request and caches access results.
// However, we're changing permissions during a test run and need fresh
// results, so reset the cache.
\Drupal::entityTypeManager()
->getAccessControlHandler($entity
->getEntityTypeId())
->resetCache();
return $entity
->access($operation, $account, TRUE);
}