88use Overblog \GraphQLBundle \Tests \Functional \App \TestKernel ;
99use Symfony \Bundle \FrameworkBundle \KernelBrowser ;
1010use Symfony \Bundle \FrameworkBundle \Test \WebTestCase ;
11+ use Symfony \Component \DependencyInjection \Container ;
1112use Symfony \Component \DependencyInjection \ContainerInterface ;
1213use Symfony \Component \Filesystem \Filesystem ;
1314use Symfony \Component \HttpFoundation \Request ;
15+ use Symfony \Component \HttpKernel \Kernel ;
1416use Symfony \Component \HttpKernel \KernelInterface ;
1517
1618use function call_user_func ;
2325use function strtolower ;
2426use function sys_get_temp_dir ;
2527
28+ if (Kernel::VERSION_ID < 70000 ) {
29+ abstract class TestCase extends BaseTestCase
30+ {
31+ protected static function getContainer (): ContainerInterface
32+ {
33+ /** @phpstan-ignore-next-line */
34+ return static ::$ kernel ->getContainer ();
35+ }
36+ }
37+ } else {
38+ abstract class TestCase extends BaseTestCase
39+ {
40+ protected static function getContainer (): Container
41+ {
42+ /** @phpstan-ignore-next-line */
43+ return static ::$ kernel ->getContainer ();
44+ }
45+ }
46+ }
47+
48+
2649/**
2750 * TestCase.
2851 */
29- abstract class TestCase extends WebTestCase
52+ abstract class BaseTestCase extends WebTestCase
3053{
3154 public const USER_RYAN = 'ryan ' ;
3255 public const USER_ADMIN = 'admin ' ;
@@ -52,7 +75,7 @@ protected static function createKernel(array $options = []): KernelInterface
5275
5376 $ options ['test_case ' ] ??= '' ;
5477
55- $ env = $ options ['environment ' ] ?? 'test ' . strtolower ($ options ['test_case ' ]);
78+ $ env = $ options ['environment ' ] ?? 'test ' . strtolower ($ options ['test_case ' ]);
5679 $ debug = $ options ['debug ' ] ?? true ;
5780
5881 return new static::$ class ($ env , $ debug , $ options ['test_case ' ]);
@@ -64,7 +87,7 @@ protected static function createKernel(array $options = []): KernelInterface
6487 public static function setUpBeforeClass (): void
6588 {
6689 $ fs = new Filesystem ();
67- $ fs ->remove (sys_get_temp_dir (). '/OverblogGraphQLBundle/ ' );
90+ $ fs ->remove (sys_get_temp_dir () . '/OverblogGraphQLBundle/ ' );
6891 }
6992
7093 protected function tearDown (): void
@@ -105,12 +128,6 @@ protected static function assertGraphQL(string $query, array $expectedData = nul
105128 static ::assertSame ($ expected , $ result , json_encode ($ result ));
106129 }
107130
108- protected static function getContainer (): ContainerInterface
109- {
110- /** @phpstan-ignore-next-line */
111- return static ::$ kernel ->getContainer ();
112- }
113-
114131 protected static function query (string $ query , string $ username , string $ testCase , string $ password = self ::DEFAULT_PASSWORD ): KernelBrowser
115132 {
116133 $ client = static ::createClientAuthenticated ($ username , $ testCase , $ password );
@@ -164,7 +181,7 @@ public static function expressionFunctionFromPhp(string $phpFunctionName)
164181 return call_user_func ([ExpressionFunction::class, 'fromPhp ' ], $ phpFunctionName );
165182 }
166183
167- return new ExpressionFunction ($ phpFunctionName , fn () => sprintf ('\%s(%s) ' , $ phpFunctionName , implode (', ' , func_get_args ())), function (): void {});
184+ return new ExpressionFunction ($ phpFunctionName , fn () => sprintf ('\%s(%s) ' , $ phpFunctionName , implode (', ' , func_get_args ())), function (): void {});
168185 }
169186
170187 /**
0 commit comments