You are here

protected function ResourceTestBase::provisionResource in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::provisionResource()
  2. 10 core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::provisionResource()

Provisions the REST resource under test.

Parameters

string[] $formats: The allowed formats for this resource.

string[] $authentication: The allowed authentication providers for this resource.

string[] $methods: The allowed methods for this resource.

16 calls to ResourceTestBase::provisionResource()
DbLogResourceTest::setUp in core/modules/dblog/tests/src/Functional/DbLogResourceTest.php
EntityResourceTestBase::provisionEntityResource in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Provides an entity resource.
FileUploadResourceTestBase::testFileUploadInvalidFileType in core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php
Tests using the file upload route with an invalid file type.
FileUploadResourceTestBase::testFileUploadLargerFileSize in core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php
Tests using the file upload route with a file size larger than allowed.
FileUploadResourceTestBase::testFileUploadMaliciousExtension in core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php
Tests using the file upload POST route with malicious extensions.

... See full list

File

core/modules/rest/tests/src/Functional/ResourceTestBase.php, line 149

Class

ResourceTestBase
Subclass this for every REST resource, every format and every auth provider.

Namespace

Drupal\Tests\rest\Functional

Code

protected function provisionResource($formats = [], $authentication = [], array $methods = [
  'GET',
  'POST',
  'PATCH',
  'DELETE',
]) {
  $this->resourceConfigStorage
    ->create([
    'id' => static::$resourceConfigId,
    'granularity' => RestResourceConfigInterface::RESOURCE_GRANULARITY,
    'configuration' => [
      'methods' => $methods,
      'formats' => $formats,
      'authentication' => $authentication,
    ],
    'status' => TRUE,
  ])
    ->save();
  $this
    ->refreshTestStateAfterRestConfigChange();
}