File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed
bundle/Form/FieldTypeHandler
tests/Form/FieldTypeHandler Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 7
7
use eZ \Publish \Core \MVC \ConfigResolverInterface ;
8
8
use eZ \Publish \SPI \FieldType \Value ;
9
9
use Netgen \Bundle \EzFormsBundle \Form \FieldTypeHandler ;
10
+ use Netgen \Bundle \EnhancedBinaryFileBundle \Core \FieldType \EnhancedBinaryFile \Value as EnhancedFileValue ;
10
11
use Symfony \Component \Form \FormBuilderInterface ;
11
12
use Symfony \Component \HttpFoundation \File \UploadedFile ;
12
13
use Symfony \Component \Validator \Constraints ;
@@ -43,11 +44,13 @@ public function convertFieldValueFromForm($data)
43
44
return null ;
44
45
}
45
46
46
- return array (
47
- 'inputUri ' => $ data ->getFileInfo ()->getRealPath (),
48
- 'fileName ' => $ data ->getClientOriginalName (),
49
- 'fileSize ' => $ data ->getSize (),
50
- 'mimeType ' => $ data ->getClientMimeType (),
47
+ return new EnhancedFileValue (
48
+ [
49
+ 'path ' => $ data ->getFileInfo ()->getRealPath (),
50
+ 'fileName ' => $ data ->getClientOriginalName (),
51
+ 'fileSize ' => $ data ->getSize (),
52
+ 'mimeType ' => $ data ->getClientMimeType (),
53
+ ]
51
54
);
52
55
}
53
56
Original file line number Diff line number Diff line change @@ -50,11 +50,11 @@ public function testConvertFieldValueFromFormWithFile()
50
50
$ file ->getClientMimeType ();
51
51
$ result = $ this ->handler ->convertFieldValueFromForm ($ file );
52
52
53
- $ this ->assertInternalType ( ' array ' , $ result );
54
- $ this ->assertEquals ($ file ->getFileInfo ()->getRealPath (), $ result[ ' inputUri ' ] );
55
- $ this ->assertEquals ($ file ->getClientOriginalName (), $ result[ ' fileName ' ] );
56
- $ this ->assertEquals ($ file ->getSize (), $ result[ ' fileSize ' ] );
57
- $ this ->assertEquals ($ file ->getClientMimeType (), $ result[ ' mimeType ' ] );
53
+ $ this ->assertInstanceOf (Value::class , $ result );
54
+ $ this ->assertEquals ($ file ->getFileInfo ()->getRealPath (), $ result-> inputUri );
55
+ $ this ->assertEquals ($ file ->getClientOriginalName (), $ result-> fileName );
56
+ $ this ->assertEquals ($ file ->getSize (), $ result-> fileSize );
57
+ $ this ->assertEquals ($ file ->getClientMimeType (), $ result-> mimeType );
58
58
}
59
59
60
60
public function testBuildFieldCreateForm ()
You can’t perform that action at this time.
0 commit comments