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