function ImageUploadTest::testFileUploadLargerFileSize

Same name in other branches
  1. 9 core/modules/ckeditor5/tests/src/Functional/ImageUploadTest.php \Drupal\Tests\ckeditor5\Functional\ImageUploadTest::testFileUploadLargerFileSize()
  2. 10 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 90

Class

ImageUploadTest
Test image upload.

Namespace

Drupal\Tests\ckeditor5\Functional

Code

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