function EditorValidationTest::testImageUploadSettingsValidation
Tests image upload settings validation.
Attributes
#[TestWith([
[
"scheme" => "public",
],
[],
])]
#[TestWith([
[
"scheme" => "private",
],
[
"image_upload.scheme" => "The file storage you selected is not a visible, readable and writable stream wrapper. Possible choices: <em class=\"placeholder\">"public"</em>.",
],
])]
#[TestWith([
[
"directory" => NULL,
],
[],
])]
#[TestWith([
[
"directory" => "",
],
[
"image_upload.directory" => "This value should not be blank.",
],
])]
#[TestWith([
[
"directory" => "inline\nimages",
],
[
"image_upload.directory" => "The image upload directory is not allowed to span multiple lines or contain control characters.",
],
])]
#[TestWith([
[
"directory" => "foo\t\t\tinline-images",
],
[
"image_upload.directory" => "The image upload directory is not allowed to span multiple lines or contain control characters.",
],
])]
#[TestWith([
[
"max_size" => NULL,
],
[],
])]
#[TestWith([
[
"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.",
],
])]
#[TestWith([
[
"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.",
],
])]
#[TestWith([
[
"max_size" => "7 exabytes",
],
[],
])]
#[TestWith([
[
"max_dimensions" => [
"width" => NULL,
"height" => 15,
],
],
[],
])]
#[TestWith([
[
"max_dimensions" => [
"width" => NULL,
"height" => NULL,
],
],
[],
])]
#[TestWith([
[
"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>.",
],
])]
#[TestWith([
[
"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 214
Class
- EditorValidationTest
- Tests validation of editor entities.
Namespace
Drupal\Tests\editor\KernelCode
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.