@@ 132-150 (lines=19) @@ | ||
129 | $response = $defaultRouter($request, $response); |
|
130 | } |
|
131 | ||
132 | public function testMissingCompulsoryParameter() |
|
133 | { |
|
134 | $container = new Picotainer([ |
|
135 | 'controller' => function () { |
|
136 | return new TestController2(); |
|
137 | }, |
|
138 | ]); |
|
139 | $parameterFetcherRegistry = ParameterFetcherRegistry::buildDefaultControllerRegistry(); |
|
140 | $controllerRegistry = new ControllerRegistry($container, $parameterFetcherRegistry, new AnnotationReader(), ['controller']); |
|
141 | $defaultRouter = new SplashDefaultRouter($container, [ |
|
142 | $controllerRegistry, |
|
143 | ], $parameterFetcherRegistry); |
|
144 | ||
145 | // We need an ID parameter |
|
146 | $request = new ServerRequest([], [], '/foo/var/bar', 'GET'); |
|
147 | $response = new HtmlResponse(''); |
|
148 | $this->expectException(SplashMissingParameterException::class); |
|
149 | $response = $defaultRouter($request, $response); |
|
150 | } |
|
151 | ||
152 | public function testMissingCompulsoryParameterWithHandler() |
|
153 | { |
|
@@ 209-226 (lines=18) @@ | ||
206 | $defaultRouter->purgeUrlsCache(); |
|
207 | } |
|
208 | ||
209 | public function testFilters() |
|
210 | { |
|
211 | $container = new Picotainer([ |
|
212 | 'controller' => function () { |
|
213 | return new TestFilteredController(); |
|
214 | }, |
|
215 | ]); |
|
216 | $parameterFetcherRegistry = ParameterFetcherRegistry::buildDefaultControllerRegistry(); |
|
217 | $controllerRegistry = new ControllerRegistry($container, $parameterFetcherRegistry, new AnnotationReader(), ['controller']); |
|
218 | $defaultRouter = new SplashDefaultRouter($container, [ |
|
219 | $controllerRegistry, |
|
220 | ], $parameterFetcherRegistry); |
|
221 | ||
222 | $request = new ServerRequest([], [], '/foo', 'GET'); |
|
223 | $response = new HtmlResponse(''); |
|
224 | $response = $defaultRouter($request, $response); |
|
225 | $this->assertEquals("42bar", (string) $response->getBody()); |
|
226 | } |
|
227 | } |
|
228 |