You are here

protected function FileResourceTestBase::getExpectedNormalizedEntity in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php \Drupal\Tests\file\Functional\Rest\FileResourceTestBase::getExpectedNormalizedEntity()
  2. 10 core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php \Drupal\Tests\file\Functional\Rest\FileResourceTestBase::getExpectedNormalizedEntity()

Returns the expected normalization of the entity.

Return value

array

Overrides EntityResourceTestBase::getExpectedNormalizedEntity

See also

::createEntity()

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

File

core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php, line 94

Class

FileResourceTestBase

Namespace

Drupal\Tests\file\Functional\Rest

Code

protected function getExpectedNormalizedEntity() {
  return [
    'changed' => [
      [
        'value' => (new \DateTime())
          ->setTimestamp($this->entity
          ->getChangedTime())
          ->setTimezone(new \DateTimeZone('UTC'))
          ->format(\DateTime::RFC3339),
        'format' => \DateTime::RFC3339,
      ],
    ],
    'created' => [
      [
        'value' => (new \DateTime())
          ->setTimestamp((int) $this->entity
          ->getCreatedTime())
          ->setTimezone(new \DateTimeZone('UTC'))
          ->format(\DateTime::RFC3339),
        'format' => \DateTime::RFC3339,
      ],
    ],
    'fid' => [
      [
        'value' => 1,
      ],
    ],
    'filemime' => [
      [
        'value' => 'text/plain',
      ],
    ],
    'filename' => [
      [
        'value' => 'drupal.txt',
      ],
    ],
    'filesize' => [
      [
        'value' => (int) $this->entity
          ->getSize(),
      ],
    ],
    'langcode' => [
      [
        'value' => 'en',
      ],
    ],
    'status' => [
      [
        'value' => TRUE,
      ],
    ],
    'uid' => [
      [
        'target_id' => (int) $this->author
          ->id(),
        'target_type' => 'user',
        'target_uuid' => $this->author
          ->uuid(),
        'url' => base_path() . 'user/' . $this->author
          ->id(),
      ],
    ],
    'uri' => [
      [
        'url' => base_path() . $this->siteDirectory . '/files/drupal.txt',
        'value' => 'public://drupal.txt',
      ],
    ],
    'uuid' => [
      [
        'value' => $this->entity
          ->uuid(),
      ],
    ],
  ];
}