function FileSizeLimitConstraintValidatorTest::testFileValidateSize
Same name in other branches
- 10 core/modules/file/tests/src/Kernel/Plugin/Validation/Constraint/FileSizeLimitConstraintValidatorTest.php \Drupal\Tests\file\Kernel\Plugin\Validation\Constraint\FileSizeLimitConstraintValidatorTest::testFileValidateSize()
@covers ::validate
File
-
core/
modules/ file/ tests/ src/ Kernel/ Plugin/ Validation/ Constraint/ FileSizeLimitConstraintValidatorTest.php, line 20
Class
- FileSizeLimitConstraintValidatorTest
- Tests the FileSizeLimitConstraintValidator.
Namespace
Drupal\Tests\file\Kernel\Plugin\Validation\ConstraintCode
public function testFileValidateSize() : void {
$validators = [
'FileSizeLimit' => [],
];
$violations = $this->validator
->validate($this->file, $validators);
$this->assertCount(0, $violations, 'No limits means no errors.');
$validators = [
'FileSizeLimit' => [
'fileLimit' => 1,
],
];
$violations = $this->validator
->validate($this->file, $validators);
$this->assertCount(1, $violations, 'Error for the file being over the limit.');
$validators = [
'FileSizeLimit' => [
'userLimit' => 1,
],
];
$violations = $this->validator
->validate($this->file, $validators);
$this->assertCount(1, $violations, 'Error for the user being over their limit.');
$validators = [
'FileSizeLimit' => [
'fileLimit' => 1,
'userLimit' => 1,
],
];
$violations = $this->validator
->validate($this->file, $validators);
$this->assertCount(2, $violations, 'Errors for both the file and their limit.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.