Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function validate($value, Constraint $constraint)
$binaryFormat = $constraint->binaryFormat;
} else {
$limitInBytes = $iniLimitSize;
$binaryFormat = true;
$binaryFormat = null === $constraint->binaryFormat ? true : $constraint->binaryFormat;
}

list($sizeAsString, $limitAsString, $suffix) = $this->factorizeSizes(0, $limitInBytes, $binaryFormat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,17 @@ public function uploadedFileErrorProvider()
'{{ suffix }}' => 'bytes',
), '1');

// access FileValidator::factorizeSizes() private method to format max file size
$reflection = new \ReflectionClass(\get_class(new FileValidator()));
$method = $reflection->getMethod('factorizeSizes');
$method->setAccessible(true);
list($sizeAsString, $limit, $suffix) = $method->invokeArgs(new FileValidator(), array(0, UploadedFile::getMaxFilesize(), false));

// it correctly parses the maxSize option and not only uses simple string comparison
// 1000M should be bigger than the ini value
$tests[] = array(UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', array(
'{{ limit }}' => UploadedFile::getMaxFilesize() / 1048576,
'{{ suffix }}' => 'MiB',
'{{ limit }}' => $limit,
'{{ suffix }}' => $suffix,
), '1000M');

// it correctly parses the maxSize option and not only uses simple string comparison
Expand Down