@@ -323,7 +323,7 @@ public function testValidation()
323323
324324 public function testValidationService ()
325325 {
326- $ container = $ this ->createContainerFromFile ('validation_annotations ' );
326+ $ container = $ this ->createContainerFromFile ('validation_annotations ' , array ( ' kernel.charset ' => ' UTF-8 ' ), false );
327327
328328 $ this ->assertInstanceOf ('Symfony\Component\Validator\Validator\ValidatorInterface ' , $ container ->get ('validator ' ));
329329 }
@@ -350,11 +350,13 @@ public function testValidationAnnotations()
350350
351351 $ calls = $ container ->getDefinition ('validator.builder ' )->getMethodCalls ();
352352
353- $ this ->assertCount (6 , $ calls );
353+ $ this ->assertCount (7 , $ calls );
354354 $ this ->assertSame ('enableAnnotationMapping ' , $ calls [4 ][0 ]);
355355 $ this ->assertEquals (array (new Reference ('annotation_reader ' )), $ calls [4 ][1 ]);
356356 $ this ->assertSame ('addMethodMapping ' , $ calls [5 ][0 ]);
357357 $ this ->assertSame (array ('loadValidatorMetadata ' ), $ calls [5 ][1 ]);
358+ $ this ->assertSame ('setMetadataCache ' , $ calls [6 ][0 ]);
359+ $ this ->assertEquals (array (new Reference ('validator.mapping.cache.symfony ' )), $ calls [6 ][1 ]);
358360 // no cache this time
359361 }
360362
@@ -368,12 +370,14 @@ public function testValidationPaths()
368370
369371 $ calls = $ container ->getDefinition ('validator.builder ' )->getMethodCalls ();
370372
371- $ this ->assertCount (7 , $ calls );
373+ $ this ->assertCount (8 , $ calls );
372374 $ this ->assertSame ('addXmlMappings ' , $ calls [3 ][0 ]);
373375 $ this ->assertSame ('addYamlMappings ' , $ calls [4 ][0 ]);
374376 $ this ->assertSame ('enableAnnotationMapping ' , $ calls [5 ][0 ]);
375377 $ this ->assertSame ('addMethodMapping ' , $ calls [6 ][0 ]);
376378 $ this ->assertSame (array ('loadValidatorMetadata ' ), $ calls [6 ][1 ]);
379+ $ this ->assertSame ('setMetadataCache ' , $ calls [7 ][0 ]);
380+ $ this ->assertEquals (array (new Reference ('validator.mapping.cache.symfony ' )), $ calls [7 ][1 ]);
377381
378382 $ xmlMappings = $ calls [3 ][1 ][0 ];
379383 $ this ->assertCount (2 , $ xmlMappings );
@@ -397,8 +401,10 @@ public function testValidationNoStaticMethod()
397401
398402 $ calls = $ container ->getDefinition ('validator.builder ' )->getMethodCalls ();
399403
400- $ this ->assertCount (4 , $ calls );
404+ $ this ->assertCount (5 , $ calls );
401405 $ this ->assertSame ('addXmlMappings ' , $ calls [3 ][0 ]);
406+ $ this ->assertSame ('setMetadataCache ' , $ calls [4 ][0 ]);
407+ $ this ->assertEquals (array (new Reference ('validator.mapping.cache.symfony ' )), $ calls [4 ][1 ]);
402408 // no cache, no annotations, no static methods
403409 }
404410
@@ -594,7 +600,7 @@ protected function createContainer(array $data = array())
594600 ), $ data )));
595601 }
596602
597- protected function createContainerFromFile ($ file , $ data = array ())
603+ protected function createContainerFromFile ($ file , $ data = array (), $ resetCompilerPasses = true )
598604 {
599605 $ cacheKey = md5 (get_class ($ this ).$ file .serialize ($ data ));
600606 if (isset (self ::$ containerCache [$ cacheKey ])) {
@@ -604,8 +610,10 @@ protected function createContainerFromFile($file, $data = array())
604610 $ container ->registerExtension (new FrameworkExtension ());
605611 $ this ->loadFromFile ($ container , $ file );
606612
607- $ container ->getCompilerPassConfig ()->setOptimizationPasses (array ());
608- $ container ->getCompilerPassConfig ()->setRemovingPasses (array ());
613+ if ($ resetCompilerPasses ) {
614+ $ container ->getCompilerPassConfig ()->setOptimizationPasses (array ());
615+ $ container ->getCompilerPassConfig ()->setRemovingPasses (array ());
616+ }
609617 $ container ->compile ();
610618
611619 return self ::$ containerCache [$ cacheKey ] = $ container ;
0 commit comments