1111
1212namespace Symfony \Bundle \FrameworkBundle \Tests \DependencyInjection ;
1313
14+ use Doctrine \Common \Annotations \Annotation ;
15+ use Symfony \Bundle \FullStack ;
1416use Symfony \Bundle \FrameworkBundle \Tests \TestCase ;
1517use Symfony \Bundle \FrameworkBundle \DependencyInjection \FrameworkExtension ;
1618use Symfony \Component \Cache \Adapter \ApcuAdapter ;
2426use Symfony \Component \DependencyInjection \Loader \ClosureLoader ;
2527use Symfony \Component \DependencyInjection \ParameterBag \ParameterBag ;
2628use Symfony \Component \DependencyInjection \Reference ;
29+ use Symfony \Component \Serializer \Serializer ;
2730use Symfony \Component \Serializer \Mapping \Factory \CacheClassMetadataFactory ;
2831use Symfony \Component \Serializer \Mapping \Loader \XmlFileLoader ;
2932use Symfony \Component \Serializer \Mapping \Loader \YamlFileLoader ;
@@ -413,7 +416,9 @@ public function testValidation()
413416
414417 $ calls = $ container ->getDefinition ('validator.builder ' )->getMethodCalls ();
415418
416- $ this ->assertCount (6 , $ calls );
419+ $ annotations = !class_exists (FullStack::class) && class_exists (Annotation::class);
420+
421+ $ this ->assertCount ($ annotations ? 7 : 6 , $ calls );
417422 $ this ->assertSame ('setConstraintValidatorFactory ' , $ calls [0 ][0 ]);
418423 $ this ->assertEquals (array (new Reference ('validator.validator_factory ' )), $ calls [0 ][1 ]);
419424 $ this ->assertSame ('setTranslator ' , $ calls [1 ][0 ]);
@@ -422,10 +427,14 @@ public function testValidation()
422427 $ this ->assertSame (array ('%validator.translation_domain% ' ), $ calls [2 ][1 ]);
423428 $ this ->assertSame ('addXmlMappings ' , $ calls [3 ][0 ]);
424429 $ this ->assertSame (array ($ xmlMappings ), $ calls [3 ][1 ]);
425- $ this ->assertSame ('addMethodMapping ' , $ calls [4 ][0 ]);
426- $ this ->assertSame (array ('loadValidatorMetadata ' ), $ calls [4 ][1 ]);
427- $ this ->assertSame ('setMetadataCache ' , $ calls [5 ][0 ]);
428- $ this ->assertEquals (array (new Reference ('validator.mapping.cache.symfony ' )), $ calls [5 ][1 ]);
430+ $ i = 3 ;
431+ if ($ annotations ) {
432+ $ this ->assertSame ('enableAnnotationMapping ' , $ calls [++$ i ][0 ]);
433+ }
434+ $ this ->assertSame ('addMethodMapping ' , $ calls [++$ i ][0 ]);
435+ $ this ->assertSame (array ('loadValidatorMetadata ' ), $ calls [$ i ][1 ]);
436+ $ this ->assertSame ('setMetadataCache ' , $ calls [++$ i ][0 ]);
437+ $ this ->assertEquals (array (new Reference ('validator.mapping.cache.symfony ' )), $ calls [$ i ][1 ]);
429438 }
430439
431440 public function testValidationService ()
@@ -536,10 +545,16 @@ public function testValidationNoStaticMethod()
536545
537546 $ calls = $ container ->getDefinition ('validator.builder ' )->getMethodCalls ();
538547
539- $ this ->assertCount (5 , $ calls );
548+ $ annotations = !class_exists (FullStack::class) && class_exists (Annotation::class);
549+
550+ $ this ->assertCount ($ annotations ? 6 : 5 , $ calls );
540551 $ this ->assertSame ('addXmlMappings ' , $ calls [3 ][0 ]);
541- $ this ->assertSame ('setMetadataCache ' , $ calls [4 ][0 ]);
542- $ this ->assertEquals (array (new Reference ('validator.mapping.cache.symfony ' )), $ calls [4 ][1 ]);
552+ $ i = 3 ;
553+ if ($ annotations ) {
554+ $ this ->assertSame ('enableAnnotationMapping ' , $ calls [++$ i ][0 ]);
555+ }
556+ $ this ->assertSame ('setMetadataCache ' , $ calls [++$ i ][0 ]);
557+ $ this ->assertEquals (array (new Reference ('validator.mapping.cache.symfony ' )), $ calls [$ i ][1 ]);
543558 // no cache, no annotations, no static methods
544559 }
545560
@@ -572,7 +587,7 @@ public function testStopwatchEnabledWithDebugModeDisabled()
572587 public function testSerializerDisabled ()
573588 {
574589 $ container = $ this ->createContainerFromFile ('default_config ' );
575- $ this ->assertFalse ( $ container ->has ('serializer ' ));
590+ $ this ->assertSame (! class_exists (FullStack::class) && class_exists (Serializer::class), $ container ->has ('serializer ' ));
576591 }
577592
578593 public function testSerializerEnabled ()
0 commit comments