File tree Expand file tree Collapse file tree 2 files changed +53
-2
lines changed
Core/FieldType/EnhancedBinaryFile Expand file tree Collapse file tree 2 files changed +53
-2
lines changed Original file line number Diff line number Diff line change @@ -127,4 +127,46 @@ public function testValidateWithMineTypesFromConfig()
127127
128128 $ this ->type ->validate ($ fieldDefinition , $ value );
129129 }
130+
131+ public function testValidateFieldSettingsWithEmptyArray ()
132+ {
133+ $ result = $ this ->type ->validateFieldSettings ([]);
134+ $ this ->assertTrue (is_array ($ result ));
135+ $ this ->assertTrue (empty ($ result ));
136+ }
137+
138+ public function testValidateFieldSettingsWithBool ()
139+ {
140+ $ result = $ this ->type ->validateFieldSettings (false );
141+ $ this ->assertTrue (is_array ($ result ));
142+ $ this ->assertFalse (empty ($ result ));
143+ $ this ->assertEquals (new ValidationError ('Field settings must be in form of an array ' ), $ result [0 ]);
144+ }
145+
146+ public function testValidateFieldSettingsWithFieldSettings ()
147+ {
148+ $ fieldSettings = [
149+ "allowedTypes " => [],
150+ "some_settings " => [],
151+ ];
152+ $ result = $ this ->type ->validateFieldSettings ($ fieldSettings );
153+ $ this ->assertTrue (is_array ($ result ));
154+ $ this ->assertFalse (empty ($ result ));
155+ $ this ->assertEquals (
156+ new ValidationError (
157+ "Setting '%setting%' is unknown " ,
158+ null ,
159+ ['setting ' => 'some_settings ' ]
160+ ),
161+ $ result [0 ]
162+ );
163+ }
164+
165+ public function testFromHash ()
166+ {
167+ $ result = $ this ->type ->fromHash ([]);
168+
169+ $ this ->assertInstanceOf (Value::class, $ result );
170+ $ this ->assertEquals (new Value (), $ result );
171+ }
130172}
Original file line number Diff line number Diff line change 33namespace Netgen \Bundle \EnhancedBinaryFileBundle \Tests \Form \FieldTypeHandler ;
44
55use eZ \Publish \Core \MVC \ConfigResolverInterface ;
6+ use eZ \Publish \Core \Repository \Values \ContentType \FieldDefinition ;
67use Netgen \Bundle \EnhancedBinaryFileBundle \Core \FieldType \EnhancedBinaryFile \Value ;
78use Netgen \Bundle \EnhancedBinaryFileBundle \Form \FieldTypeHandler \EnhancedFile ;
89use Netgen \Bundle \EzFormsBundle \Form \FieldTypeHandler ;
910use PHPUnit \Framework \TestCase ;
10- use Symfony \Component \Finder \ SplFileInfo ;
11+ use Symfony \Component \Form \ FormBuilderInterface ;
1112use Symfony \Component \HttpFoundation \File \UploadedFile ;
1213
1314class EnhancedFileTest extends TestCase
1415{
1516 /**
1617 * @var EnhancedFile
1718 */
18- protected $ handler ;
19+ protected $ handler ;
1920
2021 /**
2122 * @var \PHPUnit_Framework_MockObject_MockObject
@@ -55,4 +56,12 @@ public function testConvertFieldValueFromFormWithFile()
5556 $ this ->assertEquals ($ file ->getSize (), $ result ['fileSize ' ]);
5657 $ this ->assertEquals ($ file ->getClientMimeType (), $ result ['mimeType ' ]);
5758 }
59+
60+ public function testBuildFieldCreateForm ()
61+ {
62+ $ formBuilder = $ this ->createMock (FormBuilderInterface::class);
63+ $ fieldDefinition = new FieldDefinition ();
64+ $ lang = 'eng_US ' ;
65+ $ this ->handler ->buildFieldCreateForm ($ formBuilder , $ fieldDefinition , $ lang );
66+ }
5867}
You can’t perform that action at this time.
0 commit comments