You are here

public function MessageTest::testRelationships in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/MessageTest.php \Drupal\Tests\jsonapi\Functional\MessageTest::testRelationships()

Tests CRUD of individual resource relationship data.

Unlike the "related" routes, relationship routes only return information about the "relationship" itself, not the targeted resources. For JSON:API with Drupal, relationship routes are like looking at an entity reference field without loading the entities. It only reveals the type of the targeted resource and the target resource IDs. These type+ID combos are referred to as "resource identifiers."

Overrides ResourceTestBase::testRelationships

File

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

Class

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

Namespace

Drupal\Tests\jsonapi\Functional

Code

public function testRelationships() {

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