Update src/Symfony/Component/Form/Extension/Core/Type/FileType.php
This commit is contained in:
parent
eb0a60e1a0
commit
2fe04e1378
@ -46,6 +46,7 @@ class FileType extends AbstractType
|
|||||||
{
|
{
|
||||||
$resolver->setDefaults(array(
|
$resolver->setDefaults(array(
|
||||||
'compound' => false,
|
'compound' => false,
|
||||||
|
'data_class' => 'Symfony\Component\HttpFoundation\File\File'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,22 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
|
|||||||
|
|
||||||
class FileTypeTest extends TypeTestCase
|
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()
|
public function testDontPassValueToView()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('file');
|
$form = $this->factory->create('file');
|
||||||
|
Reference in New Issue
Block a user