$v->clean(array('tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, 'name' => '', 'size' => 0, 'type' => '')); $t->fail('->clean() throws an sfValidatorError if the file is required and no file is uploaded'); $t->skip(); } catch (sfValidatorError $e) { $t->pass('->clean() throws an sfValidatorError if the file is required and no file is uploaded'); $t->is($e->getCode(), 'required', '->clean() throws an error code of required'); } try { $v->clean(null); $t->fail('->clean() throws an sfValidatorError if the file is required and no file is uploaded'); $t->skip(); } catch (sfValidatorError $e) { $t->pass('->clean() throws an sfValidatorError if the file is required and no file is uploaded'); $t->is($e->getCode(), 'required', '->clean() throws an error code of required'); } $v = new testValidatorFile(array('required' => false)); $t->is($v->clean(array('tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, 'name' => '', 'size' => 0, 'type' => '')), null, '->clean() handles the required option correctly'); // sfValidatedFile // ->getOriginalName() ->getTempName() ->getSize() ->getType() $t->diag('->getOriginalName() ->getTempName() ->getSize() ->getType()'); sfToolkit::clearDirectory($tmpDir . '/foo'); if (is_dir($tmpDir . '/foo')) { rmdir($tmpDir . '/foo'); } $f = new sfValidatedFile('test.txt', 'text/plain', $tmpDir . '/test.txt', strlen($content)); $t->is($f->getOriginalName(), 'test.txt', '->getOriginalName() returns the original name'); $t->is($f->getTempName(), $tmpDir . '/test.txt', '->getTempName() returns the temp name'); $t->is($f->getType(), 'text/plain', '->getType() returns the content type'); $t->is($f->getSize(), strlen($content), '->getSize() returns the size of the uploaded file'); // ->save() ->isSaved() ->getSavedName() $t->diag('->save() ->isSaved() ->getSavedName()');