You are here

protected function ResourceTestBase::provisionResource in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::provisionResource()
  2. 9 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.

2 calls to ResourceTestBase::provisionResource()
EntityResourceTestBase::provisionEntityResource in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Provides an entity resource.
LayoutRestTestBase::setUp in core/modules/layout_builder/tests/src/Functional/Rest/LayoutRestTestBase.php

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