7
7
use GraphQL \Type \Schema ;
8
8
use Overblog \GraphQLBundle \Controller \ProfilerController ;
9
9
use Overblog \GraphQLBundle \DataCollector \GraphQLCollector ;
10
+ use Overblog \GraphQLBundle \Generator \TypeGenerator ;
10
11
use Overblog \GraphQLBundle \Request \Executor ;
12
+ use Overblog \GraphQLBundle \Resolver \TypeResolver ;
11
13
use PHPUnit \Framework \MockObject \MockObject ;
12
14
use PHPUnit \Framework \TestCase ;
13
15
use Symfony \Component \DependencyInjection \Exception \ServiceNotFoundException ;
@@ -45,6 +47,17 @@ protected function getMockExecutor(bool $expected = true): Executor
45
47
return $ executor ;
46
48
}
47
49
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
+
48
61
/**
49
62
* @return Profiler&MockObject
50
63
*/
@@ -58,7 +71,7 @@ protected function getMockProfiler(): Profiler
58
71
59
72
public function testInvokeWithoutProfiler (): void
60
73
{
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 );
62
75
63
76
$ this ->expectException (ServiceNotFoundException::class);
64
77
$ this ->expectExceptionMessage ('The profiler must be enabled. ' );
@@ -67,7 +80,7 @@ public function testInvokeWithoutProfiler(): void
67
80
68
81
public function testInvokeWithoutTwig (): void
69
82
{
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 );
71
84
72
85
$ this ->expectException (ServiceNotFoundException::class);
73
86
$ this ->expectExceptionMessage ('The GraphQL Profiler require twig ' );
@@ -79,10 +92,11 @@ public function testWithToken(): void
79
92
$ profilerMock = $ this ->getMockProfiler ();
80
93
$ executorMock = $ this ->getMockExecutor ();
81
94
$ routerMock = $ this ->getMockRouter ();
95
+ $ typeGeneratorMock = $ this ->getMockTypeResolver ();
82
96
83
97
/** @var Environment&MockObject $twigMock */
84
98
$ 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 );
86
100
87
101
/** @var Profiler&MockObject $profilerMock */
88
102
$ profilerMock ->expects ($ this ->once ())->method ('disable ' );
0 commit comments