77use GraphQL \Type \Schema ;
88use Overblog \GraphQLBundle \Controller \ProfilerController ;
99use Overblog \GraphQLBundle \DataCollector \GraphQLCollector ;
10+ use Overblog \GraphQLBundle \Generator \TypeGenerator ;
1011use Overblog \GraphQLBundle \Request \Executor ;
12+ use Overblog \GraphQLBundle \Resolver \TypeResolver ;
1113use PHPUnit \Framework \MockObject \MockObject ;
1214use PHPUnit \Framework \TestCase ;
1315use Symfony \Component \DependencyInjection \Exception \ServiceNotFoundException ;
@@ -45,6 +47,17 @@ protected function getMockExecutor(bool $expected = true): Executor
4547 return $ executor ;
4648 }
4749
50+ /**
51+ * @return TypeGenerator&MockObject
52+ */
53+ protected function getMockTypeResolver (int $ expected = 2 ): TypeResolver
54+ {
55+ $ typeGenerator = $ this ->getMockBuilder (TypeResolver::class)->disableOriginalConstructor ()->onlyMethods (['setIgnoreUnresolvableException ' ])->getMock ();
56+ $ typeGenerator ->expects ($ this ->exactly ($ expected ))->method ('setIgnoreUnresolvableException ' );
57+
58+ return $ typeGenerator ;
59+ }
60+
4861 /**
4962 * @return Profiler&MockObject
5063 */
@@ -58,7 +71,7 @@ protected function getMockProfiler(): Profiler
5871
5972 public function testInvokeWithoutProfiler (): void
6073 {
61- $ controller = new ProfilerController (null , null , $ this ->getMockRouter (), $ this ->getMockExecutor (false ), null );
74+ $ controller = new ProfilerController (null , null , $ this ->getMockRouter (), $ this ->getMockTypeResolver ( 0 ), $ this -> getMockExecutor (false ), null );
6275
6376 $ this ->expectException (ServiceNotFoundException::class);
6477 $ this ->expectExceptionMessage ('The profiler must be enabled. ' );
@@ -67,7 +80,7 @@ public function testInvokeWithoutProfiler(): void
6780
6881 public function testInvokeWithoutTwig (): void
6982 {
70- $ controller = new ProfilerController ($ this ->getMockProfiler (), null , $ this ->getMockRouter (), $ this ->getMockExecutor (false ), null );
83+ $ controller = new ProfilerController ($ this ->getMockProfiler (), null , $ this ->getMockRouter (), $ this ->getMockTypeResolver ( 0 ), $ this -> getMockExecutor (false ), null );
7184
7285 $ this ->expectException (ServiceNotFoundException::class);
7386 $ this ->expectExceptionMessage ('The GraphQL Profiler require twig ' );
@@ -79,10 +92,11 @@ public function testWithToken(): void
7992 $ profilerMock = $ this ->getMockProfiler ();
8093 $ executorMock = $ this ->getMockExecutor ();
8194 $ routerMock = $ this ->getMockRouter ();
95+ $ typeGeneratorMock = $ this ->getMockTypeResolver ();
8296
8397 /** @var Environment&MockObject $twigMock */
8498 $ twigMock = $ this ->getMockBuilder (Environment::class)->disableOriginalConstructor ()->onlyMethods (['render ' ])->getMock ();
85- $ controller = new ProfilerController ($ profilerMock , $ twigMock , $ routerMock , $ executorMock , null );
99+ $ controller = new ProfilerController ($ profilerMock , $ twigMock , $ routerMock , $ typeGeneratorMock , $ executorMock , null );
86100
87101 /** @var Profiler&MockObject $profilerMock */
88102 $ profilerMock ->expects ($ this ->once ())->method ('disable ' );
0 commit comments