@@ -36,7 +36,7 @@ protected function setUp()
36
36
{
37
37
parent ::setUp ();
38
38
39
- $ this ->path = sys_get_temp_dir ().DIRECTORY_SEPARATOR .'FileValidatorTest ' ;
39
+ $ this ->path = sys_get_temp_dir ().\ DIRECTORY_SEPARATOR .'FileValidatorTest ' ;
40
40
$ this ->file = fopen ($ this ->path , 'w ' );
41
41
fwrite ($ this ->file , ' ' , 1 );
42
42
}
@@ -57,6 +57,16 @@ protected function tearDown()
57
57
$ this ->file = null ;
58
58
}
59
59
60
+ // Allows the invocation of a private method
61
+ public function invokeMethod ($ object , $ methodName , $ params = array ())
62
+ {
63
+ $ reflection = new \ReflectionClass (get_class ($ object ));
64
+ $ method = $ reflection ->getMethod ($ methodName );
65
+ $ method ->setAccessible (true );
66
+
67
+ return $ method ->invokeArgs ($ object , $ params );
68
+ }
69
+
60
70
public function testNullIsValid ()
61
71
{
62
72
$ this ->validator ->validate (null , new File ());
@@ -455,11 +465,15 @@ public function uploadedFileErrorProvider()
455
465
'{{ suffix }} ' => 'bytes ' ,
456
466
), '1 ' );
457
467
468
+ list ($ sizeAsString , $ limit , $ suffix ) = $ this ->invokeMethod (
469
+ new FileValidator (), 'factorizeSizes ' , array (0 , UploadedFile::getMaxFilesize (), false )
470
+ );
471
+
458
472
// it correctly parses the maxSize option and not only uses simple string comparison
459
473
// 1000M should be bigger than the ini value
460
474
$ tests [] = array (UPLOAD_ERR_INI_SIZE , 'uploadIniSizeErrorMessage ' , array (
461
- '{{ limit }} ' => UploadedFile:: getMaxFilesize () / 1048576 ,
462
- '{{ suffix }} ' => ' MiB ' ,
475
+ '{{ limit }} ' => $ limit ,
476
+ '{{ suffix }} ' => $ suffix ,
463
477
), '1000M ' );
464
478
465
479
// it correctly parses the maxSize option and not only uses simple string comparison
0 commit comments