function EntityResourceTestBase::provisionEntityResource

Same name and namespace in other branches
  1. 11.x core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::provisionEntityResource()
  2. 10 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::provisionEntityResource()
  3. 8.9.x 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.

1 call to EntityResourceTestBase::provisionEntityResource()
ConfigurableLanguageResourceTestBase::testGetDefaultConfig in core/modules/language/tests/src/Functional/Rest/ConfigurableLanguageResourceTestBase.php
Tests a GET request for a default config entity, which has a _core key.

File

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

Class

EntityResourceTestBase
Defines a base class for testing all entity resources.

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

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