function EditorValidationTest::testImageUploadSettingsValidation

Same name in other branches
  1. 11.x core/modules/editor/tests/src/Kernel/EditorValidationTest.php \Drupal\Tests\editor\Kernel\EditorValidationTest::testImageUploadSettingsValidation()

@testWith [{"scheme": "public"}, {}] [{"scheme": "private"}, {"image_upload.scheme": "The file storage you selected is not a visible, readable and writable stream wrapper. Possible choices: <em class=\"placeholder\">&quot;public&quot;</em>."}] [{"directory": null}, {}] [{"directory": ""}, {"image_upload.directory": "This value should not be blank."}] [{"directory": "inline\nimages"}, {"image_upload.directory": "The image upload directory is not allowed to span multiple lines or contain control characters."}] [{"directory": "foo\b\b\binline-images"}, {"image_upload.directory": "The image upload directory is not allowed to span multiple lines or contain control characters."}] [{"max_size": null}, {}] [{"max_size": "foo"}, {"image_upload.max_size": "This value must be a number of bytes, optionally with a unit such as \"MB\" or \"megabytes\". <em class=\"placeholder\">foo</em> does not represent a number of bytes."}] [{"max_size": ""}, {"image_upload.max_size": "This value must be a number of bytes, optionally with a unit such as \"MB\" or \"megabytes\". <em class=\"placeholder\"></em> does not represent a number of bytes."}] [{"max_size": "7 exabytes"}, {}] [{"max_dimensions": {"width": null, "height": 15}}, {}] [{"max_dimensions": {"width": null, "height": null}}, {}] [{"max_dimensions": {"width": null, "height": 0}}, {"image_upload.max_dimensions.height": "This value should be between <em class=\"placeholder\">1</em> and <em class=\"placeholder\">99999</em>."}] [{"max_dimensions": {"width": 100000, "height": 1}}, {"image_upload.max_dimensions.width": "This value should be between <em class=\"placeholder\">1</em> and <em class=\"placeholder\">99999</em>."}]

File

core/modules/editor/tests/src/Kernel/EditorValidationTest.php, line 218

Class

EditorValidationTest
Tests validation of editor entities.

Namespace

Drupal\Tests\editor\Kernel

Code

public function testImageUploadSettingsValidation(array $invalid_setting, array $expected_message) : void {
    $this->entity
        ->setImageUploadSettings($invalid_setting + [
        'status' => TRUE,
        'scheme' => 'public',
        'directory' => 'uploaded-images',
        'max_size' => '5 MB',
        'max_dimensions' => [
            'width' => 10000,
            'height' => 10000,
        ],
    ]);
    $this->assertValidationErrors($expected_message);
}

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