You are here

protected function MediaTest::getExpectedGetRelationshipDocumentData in JSON:API 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/MediaTest.php \Drupal\Tests\jsonapi\Functional\MediaTest::getExpectedGetRelationshipDocumentData()

@todo Determine if this override should be removed in https://www.drupal.org/project/jsonapi/issues/2952522

Overrides ResourceTestBase::getExpectedGetRelationshipDocumentData

File

tests/src/Functional/MediaTest.php, line 341

Class

MediaTest
JSON API integration test for the "Media" content entity type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function getExpectedGetRelationshipDocumentData($relationship_field_name, EntityInterface $entity = NULL) {
  $data = parent::getExpectedGetRelationshipDocumentData($relationship_field_name, $entity);
  switch ($relationship_field_name) {
    case 'thumbnail':
      $data['meta'] = [
        'alt' => '',
        'width' => 180,
        'height' => 180,
        'title' => NULL,
      ];

      // @todo Make this unconditional when JSON:API requires Drupal 8.6 or newer.
      if (floatval(\Drupal::VERSION) < 8.6) {
        $data['meta']['alt'] = 'Thumbnail';
        $data['meta']['title'] = 'Llama';
      }
      return $data;
    case 'field_media_file':
      $data['meta'] = [
        'description' => NULL,
        'display' => NULL,
      ];
      return $data;
    default:
      return $data;
  }
}