Conditions | 1 |
Paths | 1 |
Total Lines | 24 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
24 | public function testMiddleware(): void |
||
25 | { |
||
26 | // setup |
||
27 | $route = '/route-with-middleware/'; |
||
28 | $router = new Router(); |
||
29 | $router->addRoute($route, function (int $i, int $j) { |
||
30 | return [ |
||
31 | $i, |
||
32 | $j |
||
33 | ]; |
||
34 | }); |
||
35 | $router->registerMiddleware($route, function () { |
||
36 | return [ |
||
37 | 1, |
||
38 | 2 |
||
39 | ]; |
||
40 | }); |
||
41 | |||
42 | // test body |
||
43 | $result = $router->callRoute($route); |
||
44 | |||
45 | // assertions |
||
46 | $this->assertEquals(1, $result[0]); |
||
47 | $this->assertEquals(2, $result[1]); |
||
48 | } |
||
50 |