function UploadedFileConstraintValidatorTest::testValidateFail
Same name in other branches
- 11.x core/modules/file/tests/src/Kernel/Validation/UploadedFileConstraintValidatorTest.php \Drupal\Tests\file\Kernel\Validation\UploadedFileConstraintValidatorTest::testValidateFail()
@covers ::validate @dataProvider validateProvider
File
-
core/
modules/ file/ tests/ src/ Kernel/ Validation/ UploadedFileConstraintValidatorTest.php, line 84
Class
- UploadedFileConstraintValidatorTest
- Tests the uploaded file validator.
Namespace
Drupal\Tests\file\Kernel\ValidationCode
public function testValidateFail(int $errorCode, string $message) : void {
$uploadedFile = new FormUploadedFile(new UploadedFile(path: $this->path, originalName: $this->filename, error: $errorCode, test: TRUE));
$violations = $uploadedFile->validate($this->validator, [
'maxSize' => $this->maxSize,
]);
$this->assertCount(1, $violations);
$violation = $violations->get(0);
$this->assertInstanceOf(TranslatableMarkup::class, $violation->getMessage());
$this->assertEquals(sprintf($message, $this->filename), $violation->getMessage());
$this->assertEquals($errorCode, $violation->getCode());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.