You are here

protected function MediaResourceTestBase::getExpectedNormalizedEntity in Drupal 8

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

Returns the expected normalization of the entity.

Return value

array

Overrides EntityResourceTestBase::getExpectedNormalizedEntity

See also

::createEntity()

1 call to MediaResourceTestBase::getExpectedNormalizedEntity()
MediaHalJsonAnonTest::getExpectedNormalizedEntity in core/modules/media/tests/src/Functional/Hal/MediaHalJsonAnonTest.php
Returns the expected normalization of the entity.
1 method overrides MediaResourceTestBase::getExpectedNormalizedEntity()
MediaHalJsonAnonTest::getExpectedNormalizedEntity in core/modules/media/tests/src/Functional/Hal/MediaHalJsonAnonTest.php
Returns the expected normalization of the entity.

File

core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php, line 148

Class

MediaResourceTestBase

Namespace

Drupal\Tests\media\Functional\Rest

Code

protected function getExpectedNormalizedEntity() {
  $file = File::load(1);
  $thumbnail = File::load(2);
  $author = User::load($this->entity
    ->getOwnerId());
  return [
    'mid' => [
      [
        'value' => 1,
      ],
    ],
    'uuid' => [
      [
        'value' => $this->entity
          ->uuid(),
      ],
    ],
    'vid' => [
      [
        'value' => 1,
      ],
    ],
    'langcode' => [
      [
        'value' => 'en',
      ],
    ],
    'bundle' => [
      [
        'target_id' => 'camelids',
        'target_type' => 'media_type',
        'target_uuid' => MediaType::load('camelids')
          ->uuid(),
      ],
    ],
    'name' => [
      [
        'value' => 'Llama',
      ],
    ],
    'field_media_file' => [
      [
        'description' => NULL,
        'display' => NULL,
        'target_id' => (int) $file
          ->id(),
        'target_type' => 'file',
        'target_uuid' => $file
          ->uuid(),
        'url' => $file
          ->createFileUrl(FALSE),
      ],
    ],
    'thumbnail' => [
      [
        'alt' => '',
        'width' => 180,
        'height' => 180,
        'target_id' => (int) $thumbnail
          ->id(),
        'target_type' => 'file',
        'target_uuid' => $thumbnail
          ->uuid(),
        'title' => NULL,
        'url' => $thumbnail
          ->createFileUrl(FALSE),
      ],
    ],
    'status' => [
      [
        'value' => TRUE,
      ],
    ],
    'created' => [
      $this
        ->formatExpectedTimestampItemValues(123456789),
    ],
    'changed' => [
      $this
        ->formatExpectedTimestampItemValues($this->entity
        ->getChangedTime()),
    ],
    'revision_created' => [
      $this
        ->formatExpectedTimestampItemValues((int) $this->entity
        ->getRevisionCreationTime()),
    ],
    'default_langcode' => [
      [
        'value' => TRUE,
      ],
    ],
    'uid' => [
      [
        'target_id' => (int) $author
          ->id(),
        'target_type' => 'user',
        'target_uuid' => $author
          ->uuid(),
        'url' => base_path() . 'user/' . $author
          ->id(),
      ],
    ],
    'revision_user' => [
      [
        'target_id' => (int) $author
          ->id(),
        'target_type' => 'user',
        'target_uuid' => $author
          ->uuid(),
        'url' => base_path() . 'user/' . $author
          ->id(),
      ],
    ],
    'revision_log_message' => [],
    'revision_translation_affected' => [
      [
        'value' => TRUE,
      ],
    ],
  ];
}