23
23
use Symfony \Component \EventDispatcher \EventDispatcher ;
24
24
use Symfony \Component \HttpKernel \DataCollector \DumpDataCollector ;
25
25
use Symfony \Component \HttpKernel \KernelInterface ;
26
+ use Symfony \Component \HttpKernel \Profiler \Profile ;
26
27
use Symfony \Component \HttpKernel \Profiler \Profiler ;
27
28
use Symfony \Component \HttpKernel \Profiler \ProfilerStorageInterface ;
29
+ use Symfony \Component \Routing \RequestContext ;
30
+ use Symfony \Component \Routing \RouteCollection ;
28
31
use Symfony \Component \Routing \RouterInterface ;
29
32
use Twig \Environment ;
30
33
use Twig \Loader \ArrayLoader ;
@@ -56,15 +59,11 @@ protected function setUp(): void
56
59
{
57
60
$ this ->kernel = $ this ->createMock (KernelInterface::class);
58
61
59
- $ profiler = $ this ->createMock (Profiler::class);
60
- $ profilerStorage = $ this ->createMock (ProfilerStorageInterface::class);
61
- $ router = $ this ->createMock (RouterInterface::class);
62
-
63
62
$ this ->container = new ContainerBuilder ();
64
63
$ this ->container ->register ('data_collector.dump ' , DumpDataCollector::class)->setPublic (true );
65
64
$ this ->container ->register ('error_handler.error_renderer.html ' , HtmlErrorRenderer::class)->setPublic (true );
66
65
$ this ->container ->register ('event_dispatcher ' , EventDispatcher::class)->setPublic (true );
67
- $ this ->container ->register ('router ' , $ router ::class)->setPublic (true );
66
+ $ this ->container ->register ('router ' , Router ::class)->setPublic (true );
68
67
$ this ->container ->register ('twig ' , Environment::class)->setPublic (true );
69
68
$ this ->container ->register ('twig_loader ' , ArrayLoader::class)->addArgument ([])->setPublic (true );
70
69
$ this ->container ->register ('twig ' , Environment::class)->addArgument (new Reference ('twig_loader ' ))->setPublic (true );
@@ -76,9 +75,9 @@ protected function setUp(): void
76
75
$ this ->container ->setParameter ('kernel.charset ' , 'UTF-8 ' );
77
76
$ this ->container ->setParameter ('debug.file_link_format ' , null );
78
77
$ this ->container ->setParameter ('profiler.class ' , [Profiler::class]);
79
- $ this ->container ->register ('profiler ' , $ profiler ::class)
78
+ $ this ->container ->register ('profiler ' , Profiler ::class)
80
79
->setPublic (true )
81
- ->addArgument (new Definition ($ profilerStorage ::class));
80
+ ->addArgument (new Definition (NullProfilerStorage ::class));
82
81
$ this ->container ->setParameter ('data_collector.templates ' , []);
83
82
$ this ->container ->set ('kernel ' , $ this ->kernel );
84
83
$ this ->container ->addCompilerPass (new RegisterListenersPass ());
@@ -207,3 +206,54 @@ private function getCompiledContainer()
207
206
return $ this ->container ;
208
207
}
209
208
}
209
+
210
+ class Router implements RouterInterface
211
+ {
212
+ private $ context ;
213
+
214
+ public function setContext (RequestContext $ context ): void
215
+ {
216
+ $ this ->context = $ context ;
217
+ }
218
+
219
+ public function getContext (): RequestContext
220
+ {
221
+ return $ this ->context ;
222
+ }
223
+
224
+ public function getRouteCollection (): RouteCollection
225
+ {
226
+ return new RouteCollection ();
227
+ }
228
+
229
+ public function generate (string $ name , array $ parameters = [], int $ referenceType = self ::ABSOLUTE_PATH ): string
230
+ {
231
+ }
232
+
233
+ public function match (string $ pathinfo ): array
234
+ {
235
+ return [];
236
+ }
237
+ }
238
+
239
+ class NullProfilerStorage implements ProfilerStorageInterface
240
+ {
241
+ public function find (?string $ ip , ?string $ url , ?int $ limit , ?string $ method , ?int $ start = null , ?int $ end = null ): array
242
+ {
243
+ return [];
244
+ }
245
+
246
+ public function read (string $ token ): ?Profile
247
+ {
248
+ return null ;
249
+ }
250
+
251
+ public function write (Profile $ profile ): bool
252
+ {
253
+ return true ;
254
+ }
255
+
256
+ public function purge ()
257
+ {
258
+ }
259
+ }
0 commit comments