function FileUploadTest::getPostDocument

Same name in other branches
  1. 8.9.x core/modules/jsonapi/tests/src/Functional/FileUploadTest.php \Drupal\Tests\jsonapi\Functional\FileUploadTest::getPostDocument()
  2. 10 core/modules/jsonapi/tests/src/Functional/FileUploadTest.php \Drupal\Tests\jsonapi\Functional\FileUploadTest::getPostDocument()
  3. 11.x core/modules/jsonapi/tests/src/Functional/FileUploadTest.php \Drupal\Tests\jsonapi\Functional\FileUploadTest::getPostDocument()

Returns the JSON:API POST document referencing the uploaded file.

Return value

array A JSON:API request document.

Overrides ResourceTestBase::getPostDocument

See also

::testPostFileUpload()

\Drupal\Tests\jsonapi\Functional\EntityTestTest::getPostDocument()

1 call to FileUploadTest::getPostDocument()
FileUploadTest::testPostFileUpload in core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
Tests using the file upload POST route; needs second request to "use" file.

File

core/modules/jsonapi/tests/src/Functional/FileUploadTest.php, line 360

Class

FileUploadTest
Tests binary data file upload route.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function getPostDocument() {
    return [
        'data' => [
            'type' => 'entity_test--entity_test',
            'attributes' => [
                'name' => 'Dramallama',
            ],
            'relationships' => [
                'field_rest_file_test' => [
                    'data' => [
                        'id' => File::load(1)->uuid(),
                        'meta' => [
                            'description' => 'The most fascinating file ever!',
                        ],
                        'type' => 'file--file',
                    ],
                ],
            ],
        ],
    ];
}

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