function MessageTest::testRelated

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

Tests GET of the 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.

Overrides ResourceTestBase::testRelated

File

core/modules/jsonapi/tests/src/Functional/MessageTest.php, line 157

Class

MessageTest
JSON:API integration test for the "Message" content entity type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

public function testRelated() : void {
    // Contact Message entities are not stored, so they cannot be retrieved.
    $this->expectException(RouteNotFoundException::class);
    $this->expectExceptionMessage('Route "jsonapi.contact_message--camelids.related" does not exist.');
    Url::fromRoute('jsonapi.contact_message--camelids.related')->toString(TRUE);
}

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