You are here

abstract protected function ResourceTestBase::setUpAuthorization in JSON:API 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::setUpAuthorization()

Sets up the necessary authorization.

In case of a test verifying publicly accessible REST resources: grant permissions to the anonymous user role.

In case of a test verifying behavior when using a particular authentication provider: create a user with a particular set of permissions.

Because of the $method parameter, it's possible to first set up authentication for only GET, then add POST, et cetera. This then also allows for verifying a 403 in case of missing authorization.

Parameters

string $method: The HTTP method for which to set up authentication.

See also

::grantPermissionsToAnonymousRole()

::grantPermissionsToAuthenticatedRole()

7 calls to ResourceTestBase::setUpAuthorization()
ResourceTestBase::testCollection in tests/src/Functional/ResourceTestBase.php
Tests GETting a collection of resources.
ResourceTestBase::testDeleteIndividual in tests/src/Functional/ResourceTestBase.php
Tests DELETEing an individual resource, plus edge cases to ensure good DX.
ResourceTestBase::testGetIndividual in tests/src/Functional/ResourceTestBase.php
Tests GETting an individual resource, plus edge cases to ensure good DX.
ResourceTestBase::testPatchIndividual in tests/src/Functional/ResourceTestBase.php
Tests PATCHing an individual resource, plus edge cases to ensure good DX.
ResourceTestBase::testPostIndividual in tests/src/Functional/ResourceTestBase.php
Tests POSTing an individual resource, plus edge cases to ensure good DX.

... See full list

45 methods override ResourceTestBase::setUpAuthorization()
ActionTest::setUpAuthorization in tests/src/Functional/ActionTest.php
Sets up the necessary authorization.
BaseFieldOverrideTest::setUpAuthorization in tests/src/Functional/BaseFieldOverrideTest.php
Sets up the necessary authorization.
BlockContentTest::setUpAuthorization in tests/src/Functional/BlockContentTest.php
Sets up the necessary authorization.
BlockContentTypeTest::setUpAuthorization in tests/src/Functional/BlockContentTypeTest.php
Sets up the necessary authorization.
BlockTest::setUpAuthorization in tests/src/Functional/BlockTest.php
Sets up the necessary authorization.

... See full list

File

tests/src/Functional/ResourceTestBase.php, line 544

Class

ResourceTestBase
Subclass this for every JSON API resource type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected abstract function setUpAuthorization($method);