Update src/Symfony/Component/Form/Extension/Core/Type/FileType.php

This commit is contained in:
Stepan Tanasiychuk 2012-07-24 15:03:14 +03:00 committed by Fabien Potencier
parent eb0a60e1a0
commit 2fe04e1378
2 changed files with 17 additions and 0 deletions

View File

@ -46,6 +46,7 @@ class FileType extends AbstractType
{
$resolver->setDefaults(array(
'compound' => false,
'data_class' => 'Symfony\Component\HttpFoundation\File\File'
));
}

View File

@ -15,6 +15,22 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
class FileTypeTest extends TypeTestCase
{
public function testFormBuilderIfEntityHasFile()
{
$entity = new \StdClass;
$entity->imageFile = $this->createUploadedFileMock('abcdef', 'original.jpg', true);
try {
$form = $this->factory->createBuilder('form', $entity)
->add('imageFile', 'file')
->getForm();
return;
} catch (\Symfony\Component\Form\Exception\FormException $e) {
$this->fail();
}
}
public function testDontPassValueToView()
{
$form = $this->factory->create('file');