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 77use eZ \Publish \Core \MVC \ConfigResolverInterface ;
88use eZ \Publish \SPI \FieldType \Value ;
99use Netgen \Bundle \EzFormsBundle \Form \FieldTypeHandler ;
10+ use Netgen \Bundle \EnhancedBinaryFileBundle \Core \FieldType \EnhancedBinaryFile \Value as EnhancedFileValue ;
1011use Symfony \Component \Form \FormBuilderInterface ;
1112use Symfony \Component \HttpFoundation \File \UploadedFile ;
1213use Symfony \Component \Validator \Constraints ;
@@ -43,11 +44,13 @@ public function convertFieldValueFromForm($data)
4344 return null ;
4445 }
4546
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+ ]
5154 );
5255 }
5356
Original file line number Diff line number Diff line change @@ -50,11 +50,11 @@ public function testConvertFieldValueFromFormWithFile()
5050 $ file ->getClientMimeType ();
5151 $ result = $ this ->handler ->convertFieldValueFromForm ($ file );
5252
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 );
5858 }
5959
6060 public function testBuildFieldCreateForm ()
You can’t perform that action at this time.
0 commit comments