You are here

protected function EntityResourceTestBase::provisionEntityResource in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::provisionEntityResource()
  2. 9 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::provisionEntityResource()

Provides an entity resource.

Parameters

bool $single_format: Provisions a single-format entity REST resource. Defaults to FALSE.

9 calls to EntityResourceTestBase::provisionEntityResource()
EntityResourceTestBase::testDelete in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Tests a DELETE request for an entity, plus edge cases to ensure good DX.
EntityResourceTestBase::testGet in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Tests a GET request for an entity, plus edge cases to ensure good DX.
EntityResourceTestBase::testPatch in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Tests a PATCH request for an entity, plus edge cases to ensure good DX.
EntityResourceTestBase::testPost in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Tests a POST request for an entity, plus edge cases to ensure good DX.
MessageResourceTestBase::testDelete in core/modules/contact/tests/src/Functional/Rest/MessageResourceTestBase.php
Tests a DELETE request for an entity, plus edge cases to ensure good DX.

... See full list

File

core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php, line 161

Class

EntityResourceTestBase
Even though there is the generic EntityResource, it's necessary for every entity type to have its own test, because they each have different fields, validation constraints, et cetera. It's not because the generic case works, that every case…

Namespace

Drupal\Tests\rest\Functional\EntityResource

Code

protected function provisionEntityResource($single_format = FALSE) {
  if ($existing = $this->resourceConfigStorage
    ->load(static::$resourceConfigId)) {
    $existing
      ->delete();
  }
  $format = $single_format ? [
    static::$format,
  ] : [
    static::$format,
    'foobar',
  ];

  // It's possible to not have any authentication providers enabled, when
  // testing public (anonymous) usage of a REST resource.
  $auth = isset(static::$auth) ? [
    static::$auth,
  ] : [];
  $this
    ->provisionResource($format, $auth);
}