You are here

protected function EntityResourceTest::buildEntityResource in JSON:API 8

Instantiates a test EntityResource.

Parameters

string $entity_type_id: The entity type ID.

string $bundle: The bundle.

\Drupal\jsonapi\ResourceType\ResourceType[] $relatable_resource_types: An array of relatable resource types, keyed by field.

bool $internal: Whether the primary resource type is internal.

Return value

\Drupal\jsonapi\Controller\EntityResource The resource.

22 calls to EntityResourceTest::buildEntityResource()
EntityResourceTest::testCreateIndividual in tests/src/Kernel/Controller/EntityResourceTest.php
@covers ::createIndividual
EntityResourceTest::testCreateIndividualConfig in tests/src/Kernel/Controller/EntityResourceTest.php
@covers ::createIndividual
EntityResourceTest::testCreateIndividualDuplicateError in tests/src/Kernel/Controller/EntityResourceTest.php
@covers ::createIndividual
EntityResourceTest::testCreateIndividualWithMissingRequiredData in tests/src/Kernel/Controller/EntityResourceTest.php
@covers ::createIndividual
EntityResourceTest::testCreateRelationship in tests/src/Kernel/Controller/EntityResourceTest.php
@covers ::createRelationship

... See full list

File

tests/src/Kernel/Controller/EntityResourceTest.php, line 885

Class

EntityResourceTest
@coversDefaultClass \Drupal\jsonapi\Controller\EntityResource @group jsonapi @group legacy

Namespace

Drupal\Tests\jsonapi\Kernel\Controller

Code

protected function buildEntityResource($entity_type_id, $bundle, array $relatable_resource_types = [], $internal = FALSE) {

  // Get the entity resource.
  $resource_type = new ResourceType($entity_type_id, $bundle, NULL, $internal);
  $resource_type
    ->setRelatableResourceTypes($relatable_resource_types);
  return new EntityResource($resource_type, $this->container
    ->get('entity_type.manager'), $this->container
    ->get('entity_field.manager'), $this->container
    ->get('plugin.manager.field.field_type'), $this->container
    ->get('jsonapi.link_manager'), $this->container
    ->get('jsonapi.resource_type.repository'), $this->container
    ->get('renderer'));
}