|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the symfony package. |
| 5 | + * (c) Fabien Potencier <fabien.potencier@symfony-project.com> |
| 6 | + * |
| 7 | + * For the full copyright and license information, please view the LICENSE |
| 8 | + * file that was distributed with this source code. |
| 9 | + */ |
| 10 | + |
| 11 | +require_once(__DIR__.'/../../bootstrap/unit.php'); |
| 12 | + |
| 13 | +$t = new lime_test(9); |
| 14 | + |
| 15 | +$tmpDir = sys_get_temp_dir(); |
| 16 | +$content = 'This is an ASCII file.'; |
| 17 | +$content2 = 'This is an ASCII file. And another one.'; |
| 18 | +file_put_contents($tmpDir.'/test.txt', $content); |
| 19 | +file_put_contents($tmpDir.'/test2.txt', $content2); |
| 20 | + |
| 21 | +// ->clean() |
| 22 | +$t->diag('->clean()'); |
| 23 | +$v = new sfValidatorFileMulti(); |
| 24 | + |
| 25 | +$f = $v->clean(array( |
| 26 | + array('tmp_name' => $tmpDir.'/test.txt'), |
| 27 | + array('tmp_name' => $tmpDir.'/test2.txt'), |
| 28 | +)); |
| 29 | + |
| 30 | +$t->ok(is_array($f), '->clean() returns an array of sfValidatedFile instances'); |
| 31 | + |
| 32 | +$t->ok($f[0] instanceof sfValidatedFile, '->clean() returns an array of sfValidatedFile'); |
| 33 | +$t->is($f[0]->getOriginalName(), '', '->clean() returns an array of sfValidatedFile with an empty original name if the name is not passed in the initial value'); |
| 34 | +$t->is($f[0]->getSize(), strlen($content), '->clean() returns an array of sfValidatedFile with a computed file size if the size is not passed in the initial value'); |
| 35 | +$t->is($f[0]->getType(), 'text/plain', '->clean() returns an array of sfValidatedFile with a guessed content type'); |
| 36 | + |
| 37 | +$t->ok($f[1] instanceof sfValidatedFile, '->clean() returns an array of sfValidatedFile'); |
| 38 | +$t->is($f[1]->getOriginalName(), '', '->clean() returns an array of sfValidatedFile with an empty original name if the name is not passed in the initial value'); |
| 39 | +$t->is($f[1]->getSize(), strlen($content2), '->clean() returns an array of sfValidatedFile with a computed file size if the size is not passed in the initial value'); |
| 40 | +$t->is($f[1]->getType(), 'text/plain', '->clean() returns an array of sfValidatedFile with a guessed content type'); |
| 41 | + |
| 42 | +unlink($tmpDir.'/test.txt'); |
| 43 | +unlink($tmpDir.'/test2.txt'); |
| 44 | +sfToolkit::clearDirectory($tmpDir.'/foo'); |
0 commit comments