2525use Symfony \Component \Cache \Adapter \ProxyAdapter ;
2626use Symfony \Component \Cache \Adapter \RedisAdapter ;
2727use Symfony \Component \DependencyInjection \ChildDefinition ;
28+ use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
2829use Symfony \Component \DependencyInjection \ContainerBuilder ;
2930use Symfony \Component \DependencyInjection \Definition ;
3031use Symfony \Component \DependencyInjection \Loader \ClosureLoader ;
@@ -589,10 +590,12 @@ public function testValidationService()
589590
590591 public function testAnnotations ()
591592 {
592- $ container = $ this ->createContainerFromFile ('full ' );
593+ $ container = $ this ->createContainerFromFile ('full ' , array (), true , false );
594+ $ container ->addCompilerPass (new TestAnnotationsPass ());
595+ $ container ->compile ();
593596
594597 $ this ->assertEquals ($ container ->getParameter ('kernel.cache_dir ' ).'/annotations ' , $ container ->getDefinition ('annotations.filesystem_cache ' )->getArgument (0 ));
595- $ this ->assertSame ('annotations.filesystem_cache ' , (string ) $ container ->getDefinition ('annotations.cached_reader ' )->getArgument (1 ));
598+ $ this ->assertSame ('annotations.filesystem_cache ' , (string ) $ container ->getDefinition ('annotation_reader ' )->getArgument (1 ));
596599 }
597600
598601 public function testFileLinkFormat ()
@@ -1051,10 +1054,10 @@ protected function createContainer(array $data = array())
10511054 ), $ data )));
10521055 }
10531056
1054- protected function createContainerFromFile ($ file , $ data = array (), $ resetCompilerPasses = true )
1057+ protected function createContainerFromFile ($ file , $ data = array (), $ resetCompilerPasses = true , $ compile = true )
10551058 {
10561059 $ cacheKey = md5 (get_class ($ this ).$ file .serialize ($ data ));
1057- if (isset (self ::$ containerCache [$ cacheKey ])) {
1060+ if ($ compile && isset (self ::$ containerCache [$ cacheKey ])) {
10581061 return self ::$ containerCache [$ cacheKey ];
10591062 }
10601063 $ container = $ this ->createContainer ($ data );
@@ -1065,7 +1068,12 @@ protected function createContainerFromFile($file, $data = array(), $resetCompile
10651068 $ container ->getCompilerPassConfig ()->setOptimizationPasses (array ());
10661069 $ container ->getCompilerPassConfig ()->setRemovingPasses (array ());
10671070 }
1068- $ container ->getCompilerPassConfig ()->setBeforeRemovingPasses (array (new AddAnnotationsCachedReaderPass (), new AddConstraintValidatorsPass (), new TranslatorPass ('translator.default ' , 'translation.reader ' )));
1071+ $ container ->getCompilerPassConfig ()->setBeforeRemovingPasses (array (new AddConstraintValidatorsPass (), new TranslatorPass ('translator.default ' , 'translation.reader ' )));
1072+ $ container ->getCompilerPassConfig ()->setAfterRemovingPasses (array (new AddAnnotationsCachedReaderPass ()));
1073+
1074+ if (!$ compile ) {
1075+ return $ container ;
1076+ }
10691077 $ container ->compile ();
10701078
10711079 return self ::$ containerCache [$ cacheKey ] = $ container ;
@@ -1158,3 +1166,15 @@ private function assertCachePoolServiceDefinitionIsCreated(ContainerBuilder $con
11581166 }
11591167 }
11601168}
1169+
1170+ /**
1171+ * Simulates ReplaceAliasByActualDefinitionPass.
1172+ */
1173+ class TestAnnotationsPass implements CompilerPassInterface
1174+ {
1175+ public function process (ContainerBuilder $ container )
1176+ {
1177+ $ container ->setDefinition ('annotation_reader ' , $ container ->getDefinition ('annotations.cached_reader ' ));
1178+ $ container ->removeDefinition ('annotations.cached_reader ' );
1179+ }
1180+ }
0 commit comments