function MediaResourceTestBase::getExpectedUnauthorizedAccessMessage

Same name in other branches
  1. 9 core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php \Drupal\Tests\media\Functional\Rest\MediaResourceTestBase::getExpectedUnauthorizedAccessMessage()
  2. 10 core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php \Drupal\Tests\media\Functional\Rest\MediaResourceTestBase::getExpectedUnauthorizedAccessMessage()
  3. 11.x core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php \Drupal\Tests\media\Functional\Rest\MediaResourceTestBase::getExpectedUnauthorizedAccessMessage()

Overrides EntityResourceTestBase::getExpectedUnauthorizedAccessMessage

1 call to MediaResourceTestBase::getExpectedUnauthorizedAccessMessage()
MediaResourceTestBase::uploadFile in core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php
This duplicates some of the 'file_upload' REST resource plugin test coverage, to be able to test it on a concrete use case.

File

core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php, line 286

Class

MediaResourceTestBase

Namespace

Drupal\Tests\media\Functional\Rest

Code

protected function getExpectedUnauthorizedAccessMessage($method) {
    if ($this->config('rest.settings')
        ->get('bc_entity_resource_permissions')) {
        return parent::getExpectedUnauthorizedAccessMessage($method);
    }
    switch ($method) {
        case 'GET':
            return "The 'view media' permission is required when the media item is published.";
        case 'POST':
            return "The following permissions are required: 'administer media' OR 'create media' OR 'create camelids media'.";
        case 'PATCH':
            return "The following permissions are required: 'update any media' OR 'update own media' OR 'camelids: edit any media' OR 'camelids: edit own media'.";
        case 'DELETE':
            return "The following permissions are required: 'delete any media' OR 'delete own media' OR 'camelids: delete any media' OR 'camelids: delete own media'.";
        default:
            return parent::getExpectedUnauthorizedAccessMessage($method);
    }
}

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