function ImageUploadTest::testFileUploadLargerFileSize

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

Tests using the file upload route with a file size larger than allowed.

File

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

Class

ImageUploadTest
Test image upload.

Namespace

Drupal\Tests\ckeditor5\Functional

Code

public function testFileUploadLargerFileSize() {
    $this->createBasicFormat();
    $this->createEditorWithUpload([
        'status' => TRUE,
        'scheme' => 'public',
        'directory' => 'inline-images',
        'max_size' => 30000,
        'max_dimensions' => [
            'width' => 0,
            'height' => 0,
        ],
    ]);
    $url = $this->getUploadUrl();
    $images = $this->getTestFiles('image');
    $large_image = $this->getTestImageByStat($images, 'size', function ($size) {
        return $size > 30000;
    });
    $small_image = $this->getTestImageByStat($images, 'size', function ($size) {
        return $size < 30000;
    });
    $response = $this->uploadRequest($url, file_get_contents($large_image->uri), 'large.jpg');
    $this->assertSame(422, $response->getStatusCode());
    $response = $this->uploadRequest($url, file_get_contents($small_image->uri), 'small.jpg');
    $this->assertSame(201, $response->getStatusCode());
}

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