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 ;
1718use Symfony \Component \Config \Definition \Builder \TreeBuilder ;
1819use Symfony \Component \Config \Definition \ConfigurationInterface ;
20+ use Symfony \Component \Config \Resource \FileResource ;
1921use Symfony \Component \DependencyInjection \ContainerBuilder ;
2022use Symfony \Component \DependencyInjection \Extension \Extension ;
2123use Symfony \Component \DependencyInjection \Extension \ExtensionInterface ;
@@ -57,6 +59,7 @@ public function testProcessWithConfigDir()
5759 $ this ->assertStringContainsString ('namespace Symfony\Component\DependencyInjection\Loader\Configurator; ' , $ content );
5860 $ this ->assertStringContainsString ('final class App extends AppReference ' , $ content );
5961 $ this ->assertStringContainsString ('public static function config(array $config): array ' , $ content );
62+ $ this ->assertEquals ([new FileResource (realpath ($ this ->tempDir ).'/reference.php ' )], $ container ->getResources ());
6063 }
6164
6265 public function testProcessIgnoresFileWriteErrors ()
@@ -78,6 +81,7 @@ public function testProcessIgnoresFileWriteErrors()
7881
7982 $ pass ->process ($ container );
8083 $ this ->assertFileDoesNotExist ($ readOnlyDir .'/reference.php ' );
84+ $ this ->assertEmpty ($ container ->getResources ());
8185 }
8286
8387 public function testProcessGeneratesExpectedReferenceFile ()
@@ -99,6 +103,23 @@ public function testProcessGeneratesExpectedReferenceFile()
99103 }
100104
101105 $ this ->assertFileEquals (__DIR__ .'/../../Fixtures/reference.php ' , $ this ->tempDir .'/reference.php ' );
106+ $ this ->assertEquals ([new FileResource (realpath ($ this ->tempDir ).'/reference.php ' )], $ container ->getResources ());
107+ }
108+
109+ #[TestWith([self ::class])]
110+ #[TestWith(['Symfony \\NotARealClass ' ])]
111+ public function testProcessWithInvalidBundleClass (string $ invalidClass )
112+ {
113+ $ container = new ContainerBuilder ();
114+ $ container ->setParameter ('.container.known_envs ' , ['test ' , 'dev ' ]);
115+
116+ $ pass = new PhpConfigReferenceDumpPass ($ this ->tempDir .'/reference.php ' , [
117+ $ invalidClass => ['dev ' => true ],
118+ ]);
119+ $ pass ->process ($ container );
120+
121+ $ referenceFile = $ this ->tempDir .'/reference.php ' ;
122+ $ this ->assertFileExists ($ referenceFile );
102123 }
103124}
104125
0 commit comments