You are here

protected function FileUploadTest::getPostDocument in JSON:API 8.2

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 tests/src/Functional/FileUploadTest.php
Tests using the file upload POST route; needs second request to "use" file.

File

tests/src/Functional/FileUploadTest.php, line 357

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