Changeset 8525
- Timestamp:
- 04/18/08 16:48:08 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/validator/sfValidatorFile.class.php
r7902 r8525 69 69 'image/gif', 70 70 ))); 71 $this->addOption('validated_file_class', 'sfValidatedFile'); 71 72 72 73 $this->addMessage('max_size', 'File is too large (maximum is %max_size% bytes).'); … … 152 153 } 153 154 154 return new sfValidatedFile($value['name'], $mimeType, $value['tmp_name'], $value['size']); 155 $class = $this->getOption('validated_file_class'); 156 157 return new $class($value['name'], $mimeType, $value['tmp_name'], $value['size']); 155 158 } 156 159 branches/1.1/test/unit/validator/sfValidatorFileTest.php
r6945 r8525 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(5 8, new lime_output_color());13 $t = new lime_test(59, new lime_output_color()); 14 14 15 15 $tmpDir = sfToolkit::getTmpDir(); … … 128 128 $t->is($f->getSize(), strlen($content), '->clean() returns a sfValidatedFile with a computed file size if the size is not passed in the initial value'); 129 129 $t->is($f->getType(), 'text/plain', '->clean() returns a sfValidatedFile with a guessed content type'); 130 131 class myValidatedFile extends sfValidatedFile 132 { 133 } 134 135 $v->setOption('validated_file_class', 'myValidatedFile'); 136 $f = $v->clean(array('tmp_name' => $tmpDir.'/test.txt')); 137 $t->ok($f instanceof myValidatedFile, '->clean() can take a "validated_file_class" option'); 130 138 131 139 foreach (array(UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_EXTENSION) as $error)