@@ -37,13 +37,11 @@ protected function setUp(): void
3737 */
3838 public function testGetTwigEnvironment (): void
3939 {
40- $ config = Config::getInstance ();
41- $ config ->settings ['environment ' ] = 'production ' ;
42- $ twig = Template::getTwigEnvironment (null );
40+ $ twig = Template::getTwigEnvironment (null , false );
4341 $ this ->assertFalse ($ twig ->isDebug ());
4442 $ this ->assertFalse (TransNode::$ enableAddDebugInfo );
45- $ config -> settings [ ' environment ' ] = ' development ' ;
46- $ twig = Template::getTwigEnvironment (null );
43+
44+ $ twig = Template::getTwigEnvironment (null , true );
4745 $ this ->assertTrue ($ twig ->isDebug ());
4846 $ this ->assertTrue (TransNode::$ enableAddDebugInfo );
4947 }
@@ -169,14 +167,15 @@ public static function providerTestRenderGettext(): array
169167 #[PreserveGlobalState(false )]
170168 public function testLoadingTwigEnvOnlyOnce (): void
171169 {
172- $ config = $ this ->createMock (Config::class);
173- $ config ->expects ($ this ->once ())->method ('getTempDir ' )->with ($ this ->equalTo ('twig ' ))->willReturn (null );
174-
175- $ template = new Template ($ config );
170+ $ twigEnvCacheProperty = new ReflectionProperty (Template::class, 'twig ' );
171+ $ twigEnvCacheProperty ->setValue (null , null );
172+ $ template = new Template ();
176173 $ this ->assertSame ("static content \n" , $ template ->render ('test/static ' ));
177-
178- $ template2 = new Template ($ config );
174+ $ twigEnv = $ twigEnvCacheProperty ->getValue ();
175+ $ this ->assertInstanceOf (Environment::class, $ twigEnv );
176+ $ template2 = new Template ();
179177 $ this ->assertSame ("static content \n" , $ template2 ->render ('test/static ' ));
178+ $ this ->assertSame ($ twigEnv , $ twigEnvCacheProperty ->getValue ());
180179 }
181180
182181 public function testDisableCache (): void
0 commit comments