function ResourceTestBase::testRelated

Same name in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::testRelated()
  2. 10 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::testRelated()
  3. 11.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::testRelated()

Tests GETing related resource of an individual resource.

Expected responses are built by making requests to 'relationship' routes. Using the fetched resource identifiers, if any, all targeted resources are fetched individually. These individual responses are then 'merged' into a single expected ResourceResponse. This is repeated for every relationship field of the resource type under test.

6 methods override ResourceTestBase::testRelated()
BlockContentTest::testRelated in core/modules/jsonapi/tests/src/Functional/BlockContentTest.php
Tests GETing related resource of an individual resource.
CommentTest::testRelated in core/modules/jsonapi/tests/src/Functional/CommentTest.php
Tests GETing related resource of an individual resource.
ItemTest::testRelated in core/modules/jsonapi/tests/src/Functional/ItemTest.php
Tests GETing related resource of an individual resource.
MenuLinkContentTest::testRelated in core/modules/jsonapi/tests/src/Functional/MenuLinkContentTest.php
Tests GETing related resource of an individual resource.
MessageTest::testRelated in core/modules/jsonapi/tests/src/Functional/MessageTest.php
Tests GETing related resource of an individual resource.

... See full list

File

core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php, line 1291

Class

ResourceTestBase
Subclass this for every JSON:API resource type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

public function testRelated() {
    $request_options = [];
    $request_options[RequestOptions::HEADERS]['Accept'] = 'application/vnd.api+json';
    $request_options = NestedArray::mergeDeep($request_options, $this->getAuthenticationRequestOptions());
    $this->doTestRelated($request_options);
    $this->setUpAuthorization('GET');
    $this->doTestRelated($request_options);
}

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