$t->is($f->getSize(), strlen($content), '->getSize() returns the size of the uploaded file'); // ->save() ->isSaved() ->getSavedName() $t->diag('->save() ->isSaved() ->getSavedName()'); $f = new sfValidatedFile('test.txt', 'text/plain', $tmpDir . '/test.txt', strlen($content)); $t->is($f->isSaved(), false, '->isSaved() returns false if the file has not been saved'); $t->is($f->getSavedName(), null, '->getSavedName() returns null if the file has not been saved'); $filename = $f->save($tmpDir . '/foo/test1.txt'); $t->is($filename, $tmpDir . '/foo/test1.txt', '->save() returns the saved filename'); $t->is(file_get_contents($tmpDir . '/foo/test1.txt'), file_get_contents($tmpDir . '/test.txt'), '->save() saves the file to the given path'); $t->is($f->isSaved(), true, '->isSaved() returns true if the file has been saved'); $t->is($f->getSavedName(), $tmpDir . '/foo/test1.txt', '->getSavedName() returns the saved file name'); $f = new sfValidatedFile('test.txt', 'text/plain', $tmpDir . '/test.txt', strlen($content), $tmpDir); $filename = $f->save($tmpDir . '/foo/test1.txt'); $t->is($filename, 'foo/test1.txt', '->save() returns the saved filename relative to the path given'); $t->is(file_get_contents($tmpDir . '/foo/test1.txt'), file_get_contents($tmpDir . '/test.txt'), '->save() saves the file to the given path'); $t->is($f->getSavedName(), $tmpDir . '/foo/test1.txt', '->getSavedName() returns the saved file name'); $filename = $f->save('foo/test1.txt'); $t->is($filename, 'foo/test1.txt', '->save() returns the saved filename relative to the path given'); $t->is(file_get_contents($tmpDir . '/foo/test1.txt'), file_get_contents($tmpDir . '/test.txt'), '->save() saves the file to the given path and uses the path if the file is not absolute'); $t->is($f->getSavedName(), $tmpDir . '/foo/test1.txt', '->getSavedName() returns the saved file name'); $filename = $f->save(); $t->is(file_get_contents($tmpDir . '/' . $filename), file_get_contents($tmpDir . '/test.txt'), '->save() returns the generated file name is none was given'); $t->is($f->getSavedName(), $tmpDir . '/' . $filename, '->getSavedName() returns the saved file name'); try { $f = new sfValidatedFile('test.txt', 'text/plain', $tmpDir . '/test.txt', strlen($content)); $f->save(); $t->fail('->save() throws an Exception if you don\'t give a filename and the path is empty'); } catch (Exception $e) { $t->pass('->save() throws an Exception if you don\'t give a filename and the path is empty'); } try {