function ResourceTestBase::provisionResource

Same name and namespace in other branches
  1. 11.x 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()
  3. 8.9.x 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.

1 call to ResourceTestBase::provisionResource()
RestJsonApiUnsupported::testApiJsonNotSupportedInRest in core/modules/jsonapi/tests/src/Functional/RestJsonApiUnsupported.php
Deploying a REST resource using api_json format results in 400 responses.

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();
}

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