@@ -133,7 +133,7 @@ public static function createResponseWithLocationDataProvider()
133133 public function testCreateResponseWithLocationAndData ()
134134 {
135135 $ testValue = array ('naviter ' => 'oudie ' );
136- $ container = $ this ->getMock ('Symfony\Component\DependencyInjection\Container ' , array ('get ' , ' getParameter ' ));
136+ $ container = $ this ->getMock ('Symfony\Component\DependencyInjection\Container ' , array ('get ' ));
137137 $ this ->setupMockedSerializer ($ container , $ testValue );
138138
139139 $ viewHandler = new ViewHandler (array ('json ' => false ));
@@ -203,9 +203,6 @@ public function testShouldReturnErrorResponseWhenDataContainsFormAndFormIsNotVal
203203
204204 $ container ->set ('fos_rest.serializer ' , $ serializer );
205205 $ container ->set ('fos_rest.view.exception_wrapper_handler ' , new ExceptionWrapperHandler ());
206- $ container ->setParameter ('fos_rest.serializer.exclusion_strategy.groups ' , 'foo ' );
207- $ container ->setParameter ('fos_rest.serializer.exclusion_strategy.version ' , '1.0 ' );
208- $ container ->setParameter ('fos_rest.serializer.serialize_null ' , false );
209206
210207 //test
211208 $ viewHandler = new ViewHandler (null , $ expectedFailedValidationCode = Codes::HTTP_I_AM_A_TEAPOT );
@@ -238,7 +235,7 @@ public function testCreateResponseWithoutLocation($format, $expected, $createVie
238235 {
239236 $ viewHandler = new ViewHandler (array ('html ' => true , 'json ' => false ));
240237
241- $ container = $ this ->getMock ('Symfony\Component\DependencyInjection\Container ' , array ('get ' , ' getParameter ' ));
238+ $ container = $ this ->getMock ('Symfony\Component\DependencyInjection\Container ' , array ('get ' ));
242239 if ('html ' === $ format ) {
243240 $ templating = $ this ->getMockBuilder ('Symfony\Bundle\FrameworkBundle\Templating\PhpEngine ' )
244241 ->setMethods (array ('render ' ))
@@ -319,17 +316,6 @@ function ($method) use ($serializer) {
319316 }
320317 )
321318 );
322-
323- $ map = array (
324- array ('fos_rest.serializer.exclusion_strategy.groups ' , 'foo ' ),
325- array ('fos_rest.serializer.exclusion_strategy.version ' , '1.0 ' ),
326- array ('fos_rest.serializer.serialize_null ' , false )
327- );
328-
329- $ container
330- ->expects ($ this ->any ())
331- ->method ('getParameter ' )
332- ->will ($ this ->returnValueMap ($ map ));
333319 }
334320
335321 public static function createResponseWithoutLocationDataProvider ()
@@ -348,7 +334,7 @@ public static function createResponseWithoutLocationDataProvider()
348334 public function testSerializeNull ($ expected , $ serializeNull )
349335 {
350336 $ viewHandler = new ViewHandler (array ('json ' => false ), 404 , 200 , $ serializeNull );
351- $ container = $ this ->getMock ('Symfony\Component\DependencyInjection\Container ' , array ('get ' , ' getParameter ' ));
337+ $ container = $ this ->getMock ('Symfony\Component\DependencyInjection\Container ' , array ('get ' ));
352338
353339 $ viewHandler ->setContainer ($ container );
354340
@@ -396,20 +382,11 @@ public static function createSerializeNullDataProvider()
396382 public function testSerializeNullDataValues ($ expected , $ serializeNull )
397383 {
398384 $ viewHandler = new ViewHandler (array ('json ' => false ), 404 , 200 );
399- $ container = $ this ->getMock ('Symfony\Component\DependencyInjection\Container ' , array ('get ' , 'getParameter ' ));
400-
401- $ viewHandler ->setContainer ($ container );
385+ $ viewHandler ->setSerializeNullStrategy ($ serializeNull );
402386
403- $ map = array (
404- array ('fos_rest.serializer.exclusion_strategy.groups ' , 'foo ' ),
405- array ('fos_rest.serializer.exclusion_strategy.version ' , '1.0 ' ),
406- array ('fos_rest.serializer.serialize_null ' , $ serializeNull )
407- );
387+ $ container = $ this ->getMock ('Symfony\Component\DependencyInjection\Container ' , array ('get ' ));
408388
409- $ container
410- ->expects ($ this ->any ())
411- ->method ('getParameter ' )
412- ->will ($ this ->returnValueMap ($ map ));
389+ $ viewHandler ->setContainer ($ container );
413390
414391 $ view = new View ();
415392 $ context = $ viewHandler ->getSerializationContext ($ view );
@@ -549,4 +526,19 @@ public function prepareTemplateParametersDataProvider()
549526 'form is wrapped as form key ' => array ($ form , array ('form ' => $ formView , 'data ' => $ formView ))
550527 );
551528 }
529+
530+ public function testConfigurableViewHandlerInterface ()
531+ {
532+ //test
533+ $ viewHandler = new ViewHandler ();
534+ $ viewHandler ->setExclusionStrategyGroups ('bar ' );
535+ $ viewHandler ->setExclusionStrategyVersion ('1.1 ' );
536+ $ viewHandler ->setSerializeNullStrategy (true );
537+
538+ $ view = new View ();
539+ $ context = $ viewHandler ->getSerializationContext ($ view );
540+ $ this ->assertEquals (array ('bar ' ), $ context ->attributes ->get ('groups ' )->getOrThrow (new \Exception ('Serialization groups not set as expected ' )));
541+ $ this ->assertEquals ('1.1 ' , $ context ->attributes ->get ('version ' )->getOrThrow (new \Exception ('Serialization version not set as expected ' )));
542+ $ this ->assertTrue ($ context ->shouldSerializeNull ());
543+ }
552544}
0 commit comments