@@ 105-123 (lines=19) @@ | ||
102 | } |
|
103 | ||
104 | ||
105 | public function testEmojiRoute() |
|
106 | { |
|
107 | $container = new Picotainer([ |
|
108 | 'controller' => function () { |
|
109 | return new TestController3(); |
|
110 | }, |
|
111 | ]); |
|
112 | $parameterFetcherRegistry = ParameterFetcherRegistry::buildDefaultControllerRegistry(); |
|
113 | $controllerAnalyzer = new ControllerAnalyzer($container, $parameterFetcherRegistry, new AnnotationReader()); |
|
114 | $controllerRegistry = new ControllerRegistry($controllerAnalyzer, ['controller']); |
|
115 | $defaultRouter = new SplashDefaultRouter($container, [ |
|
116 | $controllerRegistry, |
|
117 | ], $parameterFetcherRegistry); |
|
118 | ||
119 | $request = new ServerRequest([], [], '/'.urlencode('🍕'), 'GET'); |
|
120 | $response = new HtmlResponse(''); |
|
121 | $response = $defaultRouter($request, $response); |
|
122 | $this->assertInstanceOf(JsonResponse::class, $response); |
|
123 | } |
|
124 | ||
125 | public function testUnknownRouteWith404Handler() |
|
126 | { |
|
@@ 157-176 (lines=20) @@ | ||
154 | $response = $defaultRouter($request, $response); |
|
155 | } |
|
156 | ||
157 | public function testMissingCompulsoryParameter() |
|
158 | { |
|
159 | $container = new Picotainer([ |
|
160 | 'controller' => function () { |
|
161 | return new TestController2(); |
|
162 | }, |
|
163 | ]); |
|
164 | $parameterFetcherRegistry = ParameterFetcherRegistry::buildDefaultControllerRegistry(); |
|
165 | $controllerAnalyzer = new ControllerAnalyzer($container, $parameterFetcherRegistry, new AnnotationReader()); |
|
166 | $controllerRegistry = new ControllerRegistry($controllerAnalyzer, ['controller']); |
|
167 | $defaultRouter = new SplashDefaultRouter($container, [ |
|
168 | $controllerRegistry, |
|
169 | ], $parameterFetcherRegistry); |
|
170 | ||
171 | // We need an ID parameter |
|
172 | $request = new ServerRequest([], [], '/foo/var/bar', 'GET'); |
|
173 | $response = new HtmlResponse(''); |
|
174 | $this->expectException(SplashMissingParameterException::class); |
|
175 | $response = $defaultRouter($request, $response); |
|
176 | } |
|
177 | ||
178 | public function testMissingCompulsoryParameterWithHandler() |
|
179 | { |
|
@@ 237-255 (lines=19) @@ | ||
234 | $defaultRouter->purgeUrlsCache(); |
|
235 | } |
|
236 | ||
237 | public function testFilters() |
|
238 | { |
|
239 | $container = new Picotainer([ |
|
240 | 'controller' => function () { |
|
241 | return new TestFilteredController(); |
|
242 | }, |
|
243 | ]); |
|
244 | $parameterFetcherRegistry = ParameterFetcherRegistry::buildDefaultControllerRegistry(); |
|
245 | $controllerAnalyzer = new ControllerAnalyzer($container, $parameterFetcherRegistry, new AnnotationReader()); |
|
246 | $controllerRegistry = new ControllerRegistry($controllerAnalyzer, ['controller']); |
|
247 | $defaultRouter = new SplashDefaultRouter($container, [ |
|
248 | $controllerRegistry, |
|
249 | ], $parameterFetcherRegistry); |
|
250 | ||
251 | $request = new ServerRequest([], [], '/foo', 'GET'); |
|
252 | $response = new HtmlResponse(''); |
|
253 | $response = $defaultRouter($request, $response); |
|
254 | $this->assertEquals('42bar', (string) $response->getBody()); |
|
255 | } |
|
256 | ||
257 | public function testExpirationTag() |
|
258 | { |