mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
Fixed issue causing SimpleRouter::exception helper not to work when used within a group (issue: #551)
This commit is contained in:
@@ -19,10 +19,29 @@ class RouterCallbackExceptionHandlerTest extends \PHPUnit\Framework\TestCase
|
||||
throw new ExceptionHandlerException();
|
||||
});
|
||||
|
||||
TestRouter::debugNoReset('/404-url', 'get');
|
||||
TestRouter::router()->reset();
|
||||
TestRouter::debug('/404-url');
|
||||
}
|
||||
|
||||
$this->assertTrue(true);
|
||||
public function testExceptionHandlerCallback() {
|
||||
|
||||
TestRouter::group(['prefix' => null], function() {
|
||||
TestRouter::get('/', function() {
|
||||
return 'Hello world';
|
||||
});
|
||||
|
||||
TestRouter::get('/not-found', 'DummyController@method1');
|
||||
TestRouter::error(function(\Pecee\Http\Request $request, \Exception $exception) {
|
||||
|
||||
if($exception instanceof \Pecee\SimpleRouter\Exceptions\NotFoundHttpException && $exception->getCode() === 404) {
|
||||
return $request->setRewriteCallback(static function() {
|
||||
return 'success';
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$result = TestRouter::debugOutput('/thisdoes-not/existssss', 'get');
|
||||
$this->assertEquals('success', $result);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user