Issue #3008292: ImageItem::getUploadValidators() should be the source of truth for validating uploaded images
Merge request reports
Activity
added 54 commits
-
38b041a0...589f814d - 53 commits from branch
project:9.2.x
- 79f6e35a - Merge branch '9.2.x' into 3008292
-
38b041a0...589f814d - 53 commits from branch
added 1 commit
- 2d8068e7 - Remove redundant code from ImageWidget and QuickEditImageController.
added 1 commit
- 100520b7 - Add a kernel test of ImageItem::getUploadValidators().
added 1 commit
- 2a409a5a - See if REST and JSON:API tests pass using a similar strategy as FileUploadForm.
- Resolved by Adam G-H
177 $field_definition->setSetting('min_resolution', '32x32')->save(); 178 $validators = $item->getUploadValidators(); 179 $this->assertArrayHasKey('file_validate_is_image', $validators); 180 $this->assertSame([0, '32x32'], $validators['file_validate_image_resolution']); 181 182 $field_definition->setSetting('min_resolution', NULL) 183 ->setSetting('max_resolution', '1024x768') 184 ->save(); 185 $validators = $item->getUploadValidators(); 186 $this->assertArrayHasKey('file_validate_is_image', $validators); 187 $this->assertSame(['1024x768', 0], $validators['file_validate_image_resolution']); 188 189 $field_definition->setSetting('min_resolution', '32x32')->save(); 190 $validators = $item->getUploadValidators(); 191 $this->assertArrayHasKey('file_validate_is_image', $validators); 192 $this->assertSame(['1024x768', '32x32'], $validators['file_validate_image_resolution']); We already have explicit tests at
\Drupal\Tests\rest\Functional\FileUploadResourceTestBase::testFileUploadLargerFileSize()
and\Drupal\Tests\jsonapi\Functional\FileUploadTest::testFileUploadLargerFileSize()
for REST and JSON:API respectively — we should to add sibling test methods to ensure image upload validators run!And this would be a great starting point for those!
@wimleers It may be tricky to add sibling test methods for images, because everything in the
setUp()
method sets up a regular file field and textual data to test with. Any thoughts on how I should cleanly approach this? One option we have is to change the REST and JSON:API tests to use an image field and image data, since image fields already do everything file fields do, and more. (That's essentially what I did to fix FileItemValidationTest.) What do you think?Edited by Adam G-Hchanged this line in version 27 of the diff
added 1 commit
- 90cab856 - Add dedicated test of the media library resizing.
added 1 commit
- 231aa3f1 - Remove unnecessary comments in REST and JSON:API, and try to improve...
added 1 commit
- 8af8bfb0 - Make getUploadValidators() filter the allowed file extensions by the current...
added 359 commits
-
8af8bfb0...dfd50471 - 358 commits from branch
project:9.2.x
- ac0023cd - Merge remote-tracking branch 'origin/9.2.x' into 3008292
-
8af8bfb0...dfd50471 - 358 commits from branch
added 441 commits
-
ac0023cd...ef493a71 - 440 commits from branch
project:9.3.x
- aeb36d01 - manual rebase on 9.3.x via patch
-
ac0023cd...ef493a71 - 440 commits from branch
added 249 commits
-
aeb36d01...b78a9333 - 248 commits from branch
project:9.3.x
- b1475d65 - manual rebase on 9.3.x via patch
-
aeb36d01...b78a9333 - 248 commits from branch