function ImageUploadTest::uploadRequest

Same name in other branches
  1. 9 core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php \Drupal\Tests\ckeditor5\Functional\ImageUploadTest::uploadRequest()
  2. 11.x core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php \Drupal\Tests\ckeditor5\Functional\ImageUploadTest::uploadRequest()

Make upload request to a controller.

Parameters

\Drupal\Core\Url $url: The URL for the request.

string $file_contents: File contents.

string $file_name: Name of the file.

Return value

\Psr\Http\Message\ResponseInterface The response.

4 calls to ImageUploadTest::uploadRequest()
ImageUploadAccessTest::testCkeditor5ImageUploadRoute in core/modules/ckeditor5/tests/src/Functional/ImageUploadAccessTest.php
Test access to the CKEditor 5 image upload controller.
ImageUploadTest::testFileUploadLargerFileSize in core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php
Tests using the file upload route with a file size larger than allowed.
ImageUploadTest::testLockAfterFailedValidation in core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php
Test that lock is removed after a failed validation.
ImageUploadTest::testUploadFileExtension in core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php
Tests using the file upload route with a disallowed extension.

File

core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php, line 164

Class

ImageUploadTest
Test image upload.

Namespace

Drupal\Tests\ckeditor5\Functional

Code

protected function uploadRequest(Url $url, string $file_contents, string $file_name) {
    $request_options[RequestOptions::HEADERS] = [
        'Accept' => 'application/json',
    ];
    $request_options[RequestOptions::MULTIPART] = [
        [
            'name' => 'upload',
            'filename' => $file_name,
            'contents' => $file_contents,
        ],
    ];
    return $this->request('POST', $url, $request_options);
}

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