@@ -23,6 +23,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
23
23
* @var ObjectProphecy
24
24
*/
25
25
protected $ formFactoryMock ;
26
+
26
27
/**
27
28
* @expectedException \Linio\DynamicFormBundle\Exception\NonExistentFormException
28
29
*/
@@ -159,6 +160,51 @@ public function testIsCreatingFormWithTransformers()
159
160
$ this ->assertEquals ('foo_form ' , $ actual );
160
161
}
161
162
163
+ public function testIsCreatingFormWithHelpMessages ()
164
+ {
165
+ $ formConfiguration = [
166
+ 'foo ' => [
167
+ 'field1 ' => [
168
+ 'enabled ' => true ,
169
+ 'type ' => 'field1_type ' ,
170
+ 'help_message_provider ' => 'cache ' ,
171
+ 'options ' => [
172
+ 'help ' => 'cms:message ' ,
173
+ ],
174
+ ],
175
+ ],
176
+ ];
177
+
178
+ $ helpMessageProviderMock = $ this ->prophesize ('Linio\DynamicFormBundle\HelpMessageProvider ' );
179
+
180
+ $ helpMessageProviderMock ->getHelpMessage ('cms:message ' )
181
+ ->shouldBeCalled ()
182
+ ->willReturn ('message ' );
183
+
184
+ $ this ->formFactoryMock ->createNamedBuilder ('foo ' , 'form ' , ['foo_form_data ' ], $ formConfiguration )
185
+ ->shouldBeCalled ()
186
+ ->willReturn ($ this ->formBuilderMock ->reveal ());
187
+
188
+ $ this ->formBuilderMock ->create ('field1 ' , 'field1_type ' , ['help ' => 'message ' ])
189
+ ->shouldBeCalled ()
190
+ ->willReturn ('field1_instance ' );
191
+
192
+ $ this ->formBuilderMock ->add ('field1_instance ' )
193
+ ->shouldBeCalled ();
194
+
195
+ $ this ->formBuilderMock ->getForm ()
196
+ ->shouldBeCalled ()
197
+ ->willReturn ('foo_form ' );
198
+
199
+ $ this ->formFactory ->setFormFactory ($ this ->formFactoryMock ->reveal ());
200
+ $ this ->formFactory ->setConfiguration ($ formConfiguration );
201
+ $ this ->formFactory ->addHelpMessageProvider ('cache ' , $ helpMessageProviderMock ->reveal ());
202
+
203
+ $ actual = $ this ->formFactory ->createForm ('foo ' , ['foo_form_data ' ], $ formConfiguration );
204
+
205
+ $ this ->assertEquals ('foo_form ' , $ actual );
206
+ }
207
+
162
208
public function testIsGettingConfiguration ()
163
209
{
164
210
$ configuration = [
@@ -242,12 +288,15 @@ class MockTransformer implements DataTransformerInterface
242
288
public function setUserFormat ()
243
289
{
244
290
}
291
+
245
292
public function setInputFormat ()
246
293
{
247
294
}
295
+
248
296
public function transform ($ value )
249
297
{
250
298
}
299
+
251
300
public function reverseTransform ($ value )
252
301
{
253
302
}
0 commit comments