Changeset 8883
- Timestamp:
- 05/09/08 15:58:04 (1 year ago)
- Files:
-
- branches/1.1/lib/form/sfForm.class.php (modified) (2 diffs)
- branches/1.1/test/unit/form/sfFormTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/form/sfForm.class.php
r8696 r8883 126 126 * @param array An array of uploaded files (in the $_FILES or $_GET format) 127 127 */ 128 public function bind(array $taintedValues = null, array $taintedFiles = array())128 public function bind(array $taintedValues = null, array $taintedFiles = null) 129 129 { 130 130 $this->taintedValues = $taintedValues; … … 136 136 { 137 137 $this->taintedValues = array(); 138 } 139 140 if (is_null($this->taintedFiles)) 141 { 142 if ($this->isMultipart()) 143 { 144 throw new InvalidArgumentException('This form is multipart, which means you need to supply a files array as the bind() method second argument.'); 145 } 146 147 $this->taintedFiles = array(); 138 148 } 139 149 branches/1.1/test/unit/form/sfFormTest.php
r8756 r8883 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(8 7, new lime_output_color());13 $t = new lime_test(88, new lime_output_color()); 14 14 15 15 class FormTest extends sfForm … … 214 214 'file' => new sfValidatorFile(array('max_size' => 2)), 215 215 ))); 216 $f->bind(array( 217 1 => 'f', 218 2 => 'potencier', 219 'file' => array('name' => 'test1.txt', 'type' => 'text/plain', 'tmp_name' => '/tmp/test1.txt', 'error' => 0, 'size' => 100)) 220 ); 216 $f->setWidgetSchema(new sfWidgetFormSchema(array('file' => new sfWidgetFormInputFile()))); 217 $f->bind(array(1 => 'f', 2 => 'potencier'), array( 218 'file' => array('name' => 'test1.txt', 'type' => 'text/plain', 'tmp_name' => '/tmp/test1.txt', 'error' => 0, 'size' => 100) 219 )); 221 220 $t->is($f->getErrorSchema()->getCode(), '1 [min_length] file [max_size]', '->bind() behaves correctly with files'); 221 222 try 223 { 224 $f->bind(array(1 => 'f', 2 => 'potencier')); 225 $t->fail('->bind() second argument is mandatory if the form is multipart'); 226 } 227 catch (InvalidArgumentException $e) 228 { 229 $t->pass('->bind() second argument is mandatory if the form is multipart'); 230 } 222 231 223 232 // ->renderGlobalErrors()

