function ImageUploadTest::testUploadFileExtension

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

Tests using the file upload route with a disallowed extension.

File

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

Class

ImageUploadTest
Test image upload.

Namespace

Drupal\Tests\ckeditor5\Functional

Code

public function testUploadFileExtension() : void {
    $this->createBasicFormat();
    $this->createEditorWithUpload([
        'status' => TRUE,
        'scheme' => 'public',
        'directory' => 'inline-images',
        'max_size' => NULL,
        'max_dimensions' => [
            'width' => NULL,
            'height' => NULL,
        ],
    ]);
    $url = $this->getUploadUrl();
    $image_file = file_get_contents(current($this->getTestFiles('image'))->uri);
    $non_image_file = file_get_contents(current($this->getTestFiles('php'))->uri);
    $response = $this->uploadRequest($url, $non_image_file, 'test.php');
    $this->assertSame(422, $response->getStatusCode());
    $response = $this->uploadRequest($url, $image_file, 'test.jpg');
    $this->assertSame(201, $response->getStatusCode());
}

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