function JsonApiTopLevelResourceNormalizerTest::getTestContentEntityResource

Get a test resource type, resource object and includes.

Return value

array Indexed array with values:

  • Resource type.
  • Resource object.
  • Includes.
3 calls to JsonApiTopLevelResourceNormalizerTest::getTestContentEntityResource()
JsonApiTopLevelResourceNormalizerTest::testNormalize in core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiTopLevelResourceNormalizerTest.php
@covers ::normalize
JsonApiTopLevelResourceNormalizerTest::testResourceObjectSchema in core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiTopLevelResourceNormalizerTest.php
Test the generated resource object normalization against the schema.
JsonApiTopLevelResourceNormalizerTest::testTopLevelResourceWithSingleResource in core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiTopLevelResourceNormalizerTest.php

File

core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiTopLevelResourceNormalizerTest.php, line 274

Class

JsonApiTopLevelResourceNormalizerTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer @group jsonapi

Namespace

Drupal\Tests\jsonapi\Kernel\Normalizer

Code

protected function getTestContentEntityResource() : array {
    $resource_type = $this->container
        ->get('jsonapi.resource_type.repository')
        ->get('node', 'article');
    $resource_object = ResourceObject::createFromEntity($resource_type, $this->node);
    $includes = $this->includeResolver
        ->resolve($resource_object, 'uid,field_tags,field_image');
    return [
        $resource_type,
        $resource_object,
        $includes,
    ];
}

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