function FileResourceTestBase::getExpectedNormalizedEntity

Same name in other branches
  1. 9 core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php \Drupal\Tests\file\Functional\Rest\FileResourceTestBase::getExpectedNormalizedEntity()
  2. 8.9.x core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php \Drupal\Tests\file\Functional\Rest\FileResourceTestBase::getExpectedNormalizedEntity()
  3. 11.x core/modules/file/tests/src/Functional/Rest/FileResourceTestBase.php \Drupal\Tests\file\Functional\Rest\FileResourceTestBase::getExpectedNormalizedEntity()

Overrides EntityResourceTestBase::getExpectedNormalizedEntity

File

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

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(),
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.