function FileHalJsonAnonTest::getExpectedNormalizedEntity

Same name in other branches
  1. 9 core/modules/hal/tests/src/Functional/file/FileHalJsonAnonTest.php \Drupal\Tests\hal\Functional\file\FileHalJsonAnonTest::getExpectedNormalizedEntity()

Overrides FileResourceTestBase::getExpectedNormalizedEntity

1 call to FileHalJsonAnonTest::getExpectedNormalizedEntity()
FileHalJsonAnonTest::testGetBcUriField in core/modules/file/tests/src/Functional/Hal/FileHalJsonAnonTest.php
@group legacy @expectedDeprecation Replacing the file uri with the URL is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the provided url property instead and disable hal.settings:bc_file_uri_as_url_normalizer. Seeā€¦

File

core/modules/file/tests/src/Functional/Hal/FileHalJsonAnonTest.php, line 41

Class

FileHalJsonAnonTest
@group hal

Namespace

Drupal\Tests\file\Functional\Hal

Code

protected function getExpectedNormalizedEntity() {
    $default_normalization = parent::getExpectedNormalizedEntity();
    $normalization = $this->applyHalFieldNormalization($default_normalization);
    $url = file_create_url($this->entity
        ->getFileUri());
    // @see \Drupal\Tests\hal\Functional\EntityResource\File\FileHalJsonAnonTest::testGetBcUriField()
    if ($this->config('hal.settings')
        ->get('bc_file_uri_as_url_normalizer')) {
        $normalization['uri'][0]['value'] = $url;
    }
    $uid = $this->author
        ->id();
    return $normalization + [
        '_embedded' => [
            $this->baseUrl . '/rest/relation/file/file/uid' => [
                [
                    '_links' => [
                        'self' => [
                            'href' => $this->baseUrl . "/user/{$uid}?_format=hal_json",
                        ],
                        'type' => [
                            'href' => $this->baseUrl . '/rest/type/user/user',
                        ],
                    ],
                    'uuid' => [
                        [
                            'value' => $this->author
                                ->uuid(),
                        ],
                    ],
                ],
            ],
        ],
        '_links' => [
            'self' => [
                'href' => $url,
            ],
            'type' => [
                'href' => $this->baseUrl . '/rest/type/file/file',
            ],
            $this->baseUrl . '/rest/relation/file/file/uid' => [
                [
                    'href' => $this->baseUrl . "/user/{$uid}?_format=hal_json",
                ],
            ],
        ],
    ];
}

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