mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-16 18:50:11 +03:00
- Changed router so it supports both string and object as exception handlers. - Added `Router::error($callback)` method to `Router` class (issue #238). - Fixed issues calling `getController` and `getMethod` when callback is an object (issue #239). - Updated documentation to reflect new changes. - Added `addExceptionHandler` to `IGroupRoute` interface and `RouteGroup` class. - Other minor bugfixes and optimisations.
27 lines
827 B
PHP
27 lines
827 B
PHP
<?php
|
|
|
|
require_once 'Dummy/DummyMiddleware.php';
|
|
require_once 'Dummy/DummyController.php';
|
|
require_once 'Dummy/Exceptions/ExceptionHandlerException.php';
|
|
require_once 'Helpers/TestRouter.php';
|
|
|
|
class RouterCallbackExceptionHandlerTest extends PHPUnit_Framework_TestCase
|
|
{
|
|
|
|
public function testCallbackExceptionHandler()
|
|
{
|
|
$this->setExpectedException(ExceptionHandlerException::class);
|
|
|
|
// Match normal route on alias
|
|
TestRouter::get('/my-new-url', 'DummyController@method2');
|
|
TestRouter::get('/my-url', 'DummyController@method1');
|
|
|
|
TestRouter::error(function (\Pecee\Http\Request $request, \Exception $exception) {
|
|
throw new ExceptionHandlerException();
|
|
});
|
|
|
|
TestRouter::debugNoReset('/404-url', 'get');
|
|
TestRouter::router()->reset();
|
|
}
|
|
|
|
} |