Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
test: add tests for getRoute
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Apr 25, 2023
1 parent 3def5e8 commit 964edb3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/core.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,25 @@
// clean up
$router->configure(['app.down' => false]);
});

test('get route data', function () {
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/thispath';

$lr = new Router;

$lr->get('/thispath', ['name' => 'thisroutename', function () use($lr) {
echo json_encode($lr->getRoute());
}]);

ob_start();
$lr->run();

$data = json_decode(ob_get_contents(), true);

expect($data['path'])->toBe('/thispath');
expect($data['name'])->toBe('thisroutename');
expect($data['method'])->toBe('GET');

ob_end_clean();
});

0 comments on commit 964edb3

Please sign in to comment.