| Total Complexity | 3 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class GetCallbackUnitTest extends TestCase |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Data provider for the |
||
| 10 | * |
||
| 11 | * @return array testing dataset |
||
| 12 | */ |
||
| 13 | public function getCallbackDataProvider(): array |
||
| 23 | ] |
||
| 24 | ]; |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Testing getting callback |
||
| 29 | * |
||
| 30 | * @param string $route |
||
| 31 | * route |
||
| 32 | * @param string $url |
||
| 33 | * concrete URL |
||
| 34 | * @dataProvider getCallbackDataProvider |
||
| 35 | */ |
||
| 36 | public function testGetCallback(string $route, string $url): void |
||
| 37 | { |
||
| 38 | // setup |
||
| 39 | $router = new Router(); |
||
| 40 | $router->addRoute($route, function () { |
||
| 41 | return 'route result'; |
||
| 42 | }); |
||
| 43 | |||
| 44 | // test body |
||
| 45 | $callback = $router->getCallback($url); |
||
| 46 | |||
| 47 | // assertions |
||
| 48 | $this->assertEquals('route result', $callback()); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Testing case with unexisting callback |
||
| 53 | */ |
||
| 54 | public function testGetCallbackWithUnexistingRoute(): void |
||
| 67 | } |
||
| 68 | } |
||
| 69 |