function ImageUploadTest::testLockAfterFailedValidation

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

Test that lock is removed after a failed validation.

See also

https://www.drupal.org/project/drupal/issues/3184974

File

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

Class

ImageUploadTest
Test image upload.

Namespace

Drupal\Tests\ckeditor5\Functional

Code

public function testLockAfterFailedValidation() : void {
    $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), 'same.jpg');
    $this->assertSame(422, $response->getStatusCode());
    $response = $this->uploadRequest($url, file_get_contents($small_image->uri), 'same.jpg');
    $this->assertSame(201, $response->getStatusCode());
}

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