You are here

protected function MediaHalJsonAnonTest::getExpectedNormalizedEntity in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media/tests/src/Functional/Hal/MediaHalJsonAnonTest.php \Drupal\Tests\media\Functional\Hal\MediaHalJsonAnonTest::getExpectedNormalizedEntity()

Returns the expected normalization of the entity.

Return value

array

Overrides MediaResourceTestBase::getExpectedNormalizedEntity

See also

::createEntity()

File

core/modules/media/tests/src/Functional/Hal/MediaHalJsonAnonTest.php, line 43

Class

MediaHalJsonAnonTest
@group hal

Namespace

Drupal\Tests\media\Functional\Hal

Code

protected function getExpectedNormalizedEntity() {
  $default_normalization = parent::getExpectedNormalizedEntity();
  $normalization = $this
    ->applyHalFieldNormalization($default_normalization);
  $file = File::load(1);
  $thumbnail = File::load(2);
  $author = User::load($this->entity
    ->getOwnerId());
  return $normalization + [
    '_links' => [
      'self' => [
        'href' => $this->baseUrl . '/media/1?_format=hal_json',
      ],
      'type' => [
        'href' => $this->baseUrl . '/rest/type/media/camelids',
      ],
      $this->baseUrl . '/rest/relation/media/camelids/field_media_file' => [
        [
          'href' => $file
            ->createFileUrl(FALSE),
          'lang' => 'en',
        ],
      ],
      $this->baseUrl . '/rest/relation/media/camelids/revision_user' => [
        [
          'href' => $this->baseUrl . '/user/' . $author
            ->id() . '?_format=hal_json',
        ],
      ],
      $this->baseUrl . '/rest/relation/media/camelids/thumbnail' => [
        [
          'href' => $thumbnail
            ->createFileUrl(FALSE),
          'lang' => 'en',
        ],
      ],
      $this->baseUrl . '/rest/relation/media/camelids/uid' => [
        [
          'href' => $this->baseUrl . '/user/' . $author
            ->id() . '?_format=hal_json',
          'lang' => 'en',
        ],
      ],
    ],
    '_embedded' => [
      $this->baseUrl . '/rest/relation/media/camelids/field_media_file' => [
        [
          '_links' => [
            'self' => [
              'href' => $file
                ->createFileUrl(FALSE),
            ],
            'type' => [
              'href' => $this->baseUrl . '/rest/type/file/file',
            ],
          ],
          'lang' => 'en',
          'uuid' => [
            [
              'value' => $file
                ->uuid(),
            ],
          ],
        ],
      ],
      $this->baseUrl . '/rest/relation/media/camelids/revision_user' => [
        [
          '_links' => [
            'self' => [
              'href' => $this->baseUrl . '/user/' . $author
                ->id() . '?_format=hal_json',
            ],
            'type' => [
              'href' => $this->baseUrl . '/rest/type/user/user',
            ],
          ],
          'uuid' => [
            [
              'value' => $author
                ->uuid(),
            ],
          ],
        ],
      ],
      $this->baseUrl . '/rest/relation/media/camelids/thumbnail' => [
        [
          '_links' => [
            'self' => [
              'href' => $thumbnail
                ->createFileUrl(FALSE),
            ],
            'type' => [
              'href' => $this->baseUrl . '/rest/type/file/file',
            ],
          ],
          'lang' => 'en',
          'uuid' => [
            [
              'value' => $thumbnail
                ->uuid(),
            ],
          ],
        ],
      ],
      $this->baseUrl . '/rest/relation/media/camelids/uid' => [
        [
          '_links' => [
            'self' => [
              'href' => $this->baseUrl . '/user/' . $author
                ->id() . '?_format=hal_json',
            ],
            'type' => [
              'href' => $this->baseUrl . '/rest/type/user/user',
            ],
          ],
          'uuid' => [
            [
              'value' => $author
                ->uuid(),
            ],
          ],
          'lang' => 'en',
        ],
      ],
    ],
  ];
}