File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
DependencyInjection/Compiler
Tests/DependencyInjection/Compiler Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 1818use Symfony \Component \DependencyInjection \Extension \ConfigurationExtensionInterface ;
1919use Symfony \Component \DependencyInjection \Extension \ExtensionInterface ;
2020use Symfony \Component \DependencyInjection \Loader \Configurator \AppReference ;
21+ use Symfony \Component \HttpKernel \Bundle \BundleInterface ;
2122use Symfony \Component \Routing \Loader \Configurator \RoutesReference ;
2223
2324/**
@@ -94,6 +95,9 @@ public function process(ContainerBuilder $container): void
9495
9596 $ anyEnvExtensions = [];
9697 foreach ($ this ->bundlesDefinition as $ bundle => $ envs ) {
98+ if (!is_subclass_of ($ bundle , BundleInterface::class)) {
99+ continue ;
100+ }
97101 if (!$ extension = (new $ bundle ())->getContainerExtension ()) {
98102 continue ;
99103 }
Original file line number Diff line number Diff line change 1111
1212namespace Symfony \Bundle \FrameworkBundle \Tests \DependencyInjection \Compiler ;
1313
14+ use PHPUnit \Framework \Attributes \TestWith ;
1415use PHPUnit \Framework \TestCase ;
1516use Symfony \Bundle \FrameworkBundle \DependencyInjection \Compiler \PhpConfigReferenceDumpPass ;
1617use Symfony \Component \Config \Definition \Builder \ArrayNodeDefinition ;
@@ -100,6 +101,22 @@ public function testProcessGeneratesExpectedReferenceFile()
100101
101102 $ this ->assertFileEquals (__DIR__ .'/../../Fixtures/reference.php ' , $ this ->tempDir .'/reference.php ' );
102103 }
104+
105+ #[TestWith([self ::class])]
106+ #[TestWith(['Symfony \\NotARealClass ' ])]
107+ public function testProcessWithInvalidBundleClass (string $ invalidClass )
108+ {
109+ $ container = new ContainerBuilder ();
110+ $ container ->setParameter ('.container.known_envs ' , ['test ' , 'dev ' ]);
111+
112+ $ pass = new PhpConfigReferenceDumpPass ($ this ->tempDir .'/reference.php ' , [
113+ $ invalidClass => ['dev ' => true ],
114+ ]);
115+ $ pass ->process ($ container );
116+
117+ $ referenceFile = $ this ->tempDir .'/reference.php ' ;
118+ $ this ->assertFileExists ($ referenceFile );
119+ }
103120}
104121
105122class TestBundle extends Bundle
You can’t perform that action at this time.
0 commit comments