mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-16 02:30:09 +03:00
Development
- Fixed updatae causing middlewares to sometimes load on wrong routes. - Converted project to PSR/2. - Updated InputCollection class and added get method for easy access to values. - Complete refactor of RouterBase. - Added findRoute method to RouterBase. - It's now possible to change parameter modifiers and symbol by overwriting properties on RouterBase. - Added RouterUrlTest unit-test for testing route-urls. - Added IRestController that can be easily implemented in custom ResourceController-classes. - It's now possible to use "-" instead of "_" when using getHeader method in Request class. - Added PHPDocs. - Fixed "/" route sometimes returning "//" as url. - Optimisations and bugfixes.
This commit is contained in:
@@ -4,28 +4,29 @@ require_once 'Dummy/DummyMiddleware.php';
|
||||
require_once 'Dummy/DummyController.php';
|
||||
require_once 'Dummy/Handler/ExceptionHandler.php';
|
||||
|
||||
class MiddlewareTest extends PHPUnit_Framework_TestCase {
|
||||
use Pecee\SimpleRouter\SimpleRouter as SimpleRouter;
|
||||
|
||||
public function testMiddlewareFound() {
|
||||
class MiddlewareTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testMiddlewareFound()
|
||||
{
|
||||
SimpleRouter::router()->reset();
|
||||
SimpleRouter::request()->setMethod('get');
|
||||
SimpleRouter::request()->setUri('/my/test/url');
|
||||
|
||||
\Pecee\SimpleRouter\RouterBase::getInstance()->reset();
|
||||
\Pecee\SimpleRouter\SimpleRouter::request()->setMethod('get');
|
||||
\Pecee\SimpleRouter\SimpleRouter::request()->setUri('/my/test/url');
|
||||
SimpleRouter::group(['exceptionHandler' => 'ExceptionHandler'], function () {
|
||||
SimpleRouter::get('/my/test/url', 'DummyController@start', ['middleware' => 'DummyMiddleware']);
|
||||
});
|
||||
|
||||
\Pecee\SimpleRouter\SimpleRouter::group(['exceptionHandler' => 'ExceptionHandler'], function() {
|
||||
\Pecee\SimpleRouter\SimpleRouter::get('/my/test/url', 'DummyController@start', ['middleware' => 'DummyMiddleware']);
|
||||
});
|
||||
$found = false;
|
||||
|
||||
$found = false;
|
||||
try {
|
||||
SimpleRouter::start();
|
||||
} catch (\Exception $e) {
|
||||
$found = ($e instanceof MiddlewareLoadedException);
|
||||
}
|
||||
|
||||
try {
|
||||
\Pecee\SimpleRouter\SimpleRouter::start();
|
||||
}catch(\Exception $e) {
|
||||
$found = ($e instanceof MiddlewareLoadedException);
|
||||
}
|
||||
|
||||
$this->assertTrue($found);
|
||||
|
||||
}
|
||||
$this->assertTrue($found);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user