You are here

protected function FileUploadTest::getPostDocument in Drupal 9

Same name and namespace in other branches
  1. 8 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 359

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