@@ -169,13 +169,52 @@ public function testCreateThrowsUnderstandableException()
169
169
$ this ->factory ->create (new \stdClass ());
170
170
}
171
171
172
+ public function testCreateUsesBlockPrefixIfTypeGivenAsString ()
173
+ {
174
+ $ options = array ('a ' => '1 ' , 'b ' => '2 ' );
175
+ $ resolvedOptions = array ('a ' => '2 ' , 'b ' => '3 ' );
176
+
177
+ // the interface does not have the method, so use the real class
178
+ $ resolvedType = $ this ->getMockBuilder ('Symfony\Component\Form\ResolvedFormType ' )
179
+ ->disableOriginalConstructor ()
180
+ ->getMock ();
181
+
182
+ $ resolvedType ->expects ($ this ->any ())
183
+ ->method ('getBlockPrefix ' )
184
+ ->willReturn ('TYPE_PREFIX ' );
185
+
186
+ $ this ->registry ->expects ($ this ->any ())
187
+ ->method ('getType ' )
188
+ ->with ('TYPE ' )
189
+ ->will ($ this ->returnValue ($ resolvedType ));
190
+
191
+ $ resolvedType ->expects ($ this ->once ())
192
+ ->method ('createBuilder ' )
193
+ ->with ($ this ->factory , 'TYPE_PREFIX ' , $ options )
194
+ ->will ($ this ->returnValue ($ this ->builder ));
195
+
196
+ $ this ->builder ->expects ($ this ->any ())
197
+ ->method ('getOptions ' )
198
+ ->will ($ this ->returnValue ($ resolvedOptions ));
199
+
200
+ $ resolvedType ->expects ($ this ->once ())
201
+ ->method ('buildForm ' )
202
+ ->with ($ this ->builder , $ resolvedOptions );
203
+
204
+ $ this ->builder ->expects ($ this ->once ())
205
+ ->method ('getForm ' )
206
+ ->will ($ this ->returnValue ('FORM ' ));
207
+
208
+ $ this ->assertSame ('FORM ' , $ this ->factory ->create ('TYPE ' , null , $ options ));
209
+ }
210
+
172
211
public function testCreateUsesTypeNameIfTypeGivenAsString ()
173
212
{
174
213
$ options = array ('a ' => '1 ' , 'b ' => '2 ' );
175
214
$ resolvedOptions = array ('a ' => '2 ' , 'b ' => '3 ' );
176
215
$ resolvedType = $ this ->getMockResolvedType ();
177
216
178
- $ this ->registry ->expects ($ this ->once ())
217
+ $ this ->registry ->expects ($ this ->any ())
179
218
->method ('getType ' )
180
219
->with ('TYPE ' )
181
220
->will ($ this ->returnValue ($ resolvedType ));
@@ -206,7 +245,7 @@ public function testCreateStripsNamespaceOffTypeName()
206
245
$ resolvedOptions = array ('a ' => '2 ' , 'b ' => '3 ' );
207
246
$ resolvedType = $ this ->getMockResolvedType ();
208
247
209
- $ this ->registry ->expects ($ this ->once ())
248
+ $ this ->registry ->expects ($ this ->any ())
210
249
->method ('getType ' )
211
250
->with ('Vendor\Name\Space\UserForm ' )
212
251
->will ($ this ->returnValue ($ resolvedType ));
@@ -237,7 +276,7 @@ public function testCreateStripsTypeSuffixOffTypeName()
237
276
$ resolvedOptions = array ('a ' => '2 ' , 'b ' => '3 ' );
238
277
$ resolvedType = $ this ->getMockResolvedType ();
239
278
240
- $ this ->registry ->expects ($ this ->once ())
279
+ $ this ->registry ->expects ($ this ->any ())
241
280
->method ('getType ' )
242
281
->with ('Vendor\Name\Space\UserType ' )
243
282
->will ($ this ->returnValue ($ resolvedType ));
@@ -268,7 +307,7 @@ public function testCreateDoesNotStripTypeSuffixIfResultEmpty()
268
307
$ resolvedOptions = array ('a ' => '2 ' , 'b ' => '3 ' );
269
308
$ resolvedType = $ this ->getMockResolvedType ();
270
309
271
- $ this ->registry ->expects ($ this ->once ())
310
+ $ this ->registry ->expects ($ this ->any ())
272
311
->method ('getType ' )
273
312
->with ('Vendor\Name\Space\Type ' )
274
313
->will ($ this ->returnValue ($ resolvedType ));
@@ -299,7 +338,7 @@ public function testCreateConvertsTypeToUnderscoreSyntax()
299
338
$ resolvedOptions = array ('a ' => '2 ' , 'b ' => '3 ' );
300
339
$ resolvedType = $ this ->getMockResolvedType ();
301
340
302
- $ this ->registry ->expects ($ this ->once ())
341
+ $ this ->registry ->expects ($ this ->any ())
303
342
->method ('getType ' )
304
343
->with ('Vendor\Name\Space\MyProfileHTMLType ' )
305
344
->will ($ this ->returnValue ($ resolvedType ));
0 commit comments