1616use Symfony \Component \Routing \RouteCollectionBuilder ;
1717use TheCodingMachine \Graphqlite \Bundle \GraphqliteBundle ;
1818use Symfony \Component \Security \Core \User \User ;
19+ use function class_exists ;
20+ use function serialize ;
1921
2022class GraphqliteTestingKernel extends Kernel
2123{
@@ -50,8 +52,28 @@ class GraphqliteTestingKernel extends Kernel
5052 * @var int|null
5153 */
5254 private $ maximumQueryDepth ;
55+ /**
56+ * @var array|string[]
57+ */
58+ private $ controllersNamespace ;
59+ /**
60+ * @var array|string[]
61+ */
62+ private $ typesNamespace ;
5363
54- public function __construct (bool $ enableSession = true , ?string $ enableLogin = null , bool $ enableSecurity = true , ?string $ enableMe = null , bool $ introspection = true , ?int $ maximumQueryComplexity = null , ?int $ maximumQueryDepth = null )
64+ /**
65+ * @param string[] $controllersNamespace
66+ * @param string[] $typesNamespace
67+ */
68+ public function __construct (bool $ enableSession = true ,
69+ ?string $ enableLogin = null ,
70+ bool $ enableSecurity = true ,
71+ ?string $ enableMe = null ,
72+ bool $ introspection = true ,
73+ ?int $ maximumQueryComplexity = null ,
74+ ?int $ maximumQueryDepth = null ,
75+ array $ controllersNamespace = ['TheCodingMachine \\Graphqlite \\Bundle \\Tests \\Fixtures \\Controller \\' ],
76+ array $ typesNamespace = ['TheCodingMachine \\Graphqlite \\Bundle \\Tests \\Fixtures \\Types \\' , 'TheCodingMachine \\Graphqlite \\Bundle \\Tests \\Fixtures \\Entities \\' ])
5577 {
5678 parent ::__construct ('test ' , true );
5779 $ this ->enableSession = $ enableSession ;
@@ -61,15 +83,18 @@ public function __construct(bool $enableSession = true, ?string $enableLogin = n
6183 $ this ->introspection = $ introspection ;
6284 $ this ->maximumQueryComplexity = $ maximumQueryComplexity ;
6385 $ this ->maximumQueryDepth = $ maximumQueryDepth ;
86+ $ this ->controllersNamespace = $ controllersNamespace ;
87+ $ this ->typesNamespace = $ typesNamespace ;
6488 }
6589
6690 public function registerBundles ()
6791 {
68- return [
69- new FrameworkBundle (),
70- new SecurityBundle (),
71- new GraphqliteBundle (),
72- ];
92+ $ bundles = [ new FrameworkBundle () ];
93+ if (class_exists (SecurityBundle::class)) {
94+ $ bundles [] = new SecurityBundle ();
95+ }
96+ $ bundles [] = new GraphqliteBundle ();
97+ return $ bundles ;
7398 }
7499
75100 public function configureContainer (ContainerBuilder $ c , LoaderInterface $ loader )
@@ -133,8 +158,8 @@ public function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
133158
134159 $ graphqliteConf = array (
135160 'namespace ' => [
136- 'controllers ' => [ ' TheCodingMachine \\ Graphqlite \\ Bundle \\ Tests \\ Fixtures \\ Controller \\' ] ,
137- 'types ' => [ ' TheCodingMachine \\ Graphqlite \\ Bundle \\ Tests \\ Fixtures \\ Types \\' , ' TheCodingMachine \\ Graphqlite \\ Bundle \\ Tests \\ Fixtures \\ Entities \\' ]
161+ 'controllers ' => $ this -> controllersNamespace ,
162+ 'types ' => $ this -> typesNamespace
138163 ],
139164 );
140165
@@ -176,6 +201,6 @@ protected function configureRoutes(/*RoutingConfigurator*/ $routes)
176201
177202 public function getCacheDir ()
178203 {
179- return __DIR__ .'/../cache/ ' .($ this ->enableSession ?'withSession ' :'withoutSession ' ).$ this ->enableLogin .($ this ->enableSecurity ?'withSecurity ' :'withoutSecurity ' ).$ this ->enableMe .'_ ' .($ this ->introspection ?'withIntrospection ' :'withoutIntrospection ' ).'_ ' .$ this ->maximumQueryComplexity .'_ ' .$ this ->maximumQueryDepth ;
204+ return __DIR__ .'/../cache/ ' .($ this ->enableSession ?'withSession ' :'withoutSession ' ).$ this ->enableLogin .($ this ->enableSecurity ?'withSecurity ' :'withoutSecurity ' ).$ this ->enableMe .'_ ' .($ this ->introspection ?'withIntrospection ' :'withoutIntrospection ' ).'_ ' .$ this ->maximumQueryComplexity .'_ ' .$ this ->maximumQueryDepth . ' _ ' . md5 ( serialize ( $ this -> controllersNamespace ). ' _ ' . md5 ( serialize ( $ this -> typesNamespace ))) ;
180205 }
181206}
0 commit comments