function 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\FunctionalCode
public function testUploadFileExtension() : void {
  $this->createBasicFormat();
  $this->createEditorWithUpload([
    'status' => TRUE,
    'scheme' => 'public',
    'directory' => 'inline-images',
    'max_size' => '',
    'max_dimensions' => [
      'width' => 0,
      'height' => 0,
    ],
  ]);
  $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.